Question 1:
Write a MATLAB function my_meshgrid which that provides the functionality you expect from the meshgrid
function of MATLAB. The function should work in the following manner.
[X, Y] = my_meshgrid (x, y);
The function my_meshgrid takes two vectors x and y as input and return two matrices X and Y where both X and
Y have same dimensions equal to length(y) by length(x). Matrix X is produced such that x is considered as
a row-vector and replicated length(y) number of times. Similarly, Y is produced such that y is considered as a
column-vector and replicated length(x) times.
Hint: Consider implementing my_meshgrid using loops.
As an example, if,
x= [1 2] and y = [3 4 5]
As x is 1x2 vector and y is 1x3 matrix, the output X and Y will both be matrices of dimension 3x2. The following
output is expected:
X =
1 2
1 2
1 2
Y =
3 3
4 4
5 5