Here is a portion of my code:

dx=0.05;

dy=0.05;

im=41;

jm=21;

x=[-1:dx:1];

y=[0:dy:1];

for i=1:1:im

for j=1:1:jm

u(i,j)=2*y(j)*(1-x(i)^2);

v(i,j)=-2*x(i)*(1-y(j)^2);

psi(i,j)=x(i)^2-(x(i)^2)*y(j)^2+y(j)^2;

end

end

figure

axes('position',[.1 .3 .8 .6]);

contour(x,y,psi);

axes('position',[.1 .1 .8 .1]);

pcolor([0:100;0:100]);

figure

quiver(x,y,u,v);

I get the following error message for both plots: 'The size of X must match the size of Z or the number of columns of Z.'

Using the meshgrid function reverses the dimensions for some reason (it gives (21X41) for x and y when the actual size is x(41), y(21)). If I add this dimension by hand to get x and y of (41X21) and adding zeros to all other rows/columns, my plots are incorrect. Why don't the dimensions/assignment of (x,y,u,v) work for these plots?

I am clearly not understanding how the contour and quiver functions interpret the input.

Please help if you can. Thank you very much!