I'm having trouble using the mesh or surf functions in matlab to make a 3d plot. I have a defined range of x values x=0:.5:5 and y values y=-5:.5:5 These both come out to 21 values. I also have a 21x21 matrix C with rows corresponding to x values and columns to y values.
I've been trying
figure();
x=0:.5:5;
z=-5:.5:5;
mesh(z,x,C);
but all I get is graph of a plane when the matrix actually has a very diverse set of elements. Any thoughts as to what I'm doing wrong? Thanks
Plot-commands usually wants the dimensions of all arguments to be the same. By this, it means, that it takes a value at any place of the first argument and can take the values of the corresponding places in the other arguments. If the dimensions don't agree, it assumes that they are the same and takes the last argument as "multiple plot"-commands.
What you have to do, is to create a meshgrid by using this command. This will take two vectors $x$ and $y$ and returns two rank-1 matrices with that one collumn repeated to fit the length of the other vector.