Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In problems 2 and 3, we will practice using array operations to compute the foll

ID: 3833839 • Letter: I

Question

In problems 2 and 3, we will practice using array operations to compute the following functions of 2 variables. f(x, y). The 3D plots are shown below to demonstrate what these functions look like. You are not doing the plotting here yet. Cody will do it for you. The value of N will be randomized at each submission, and will be created by the auto grader. Do not modify the given value of N. Create a variable vec as a row vector having values from -N to N. with an increment size of + 1. Create a variable X as a matrix of size [(2N+1) x (2N+1)] with each row being vec, thus having duplicates of vec for 2N+1 rows. Create a variable Y as a matrix of size [(2N+1) x (2N+1)) with each column being transposed vec, thus having duplicates of transposed vec for 2N+1 columns.

Explanation / Answer

N = input('Type a value of N: ') ; %taking value of N from prompt
vec=-N:1:N; %creating vec
vec=(vec)
X=[[];repmat(vec,((2*N)+1),1)] %Adding 2n+1 number of rows of vec in X
Y=X.' %Adding 2n+1 number of columns of vec in Y