I know this seems like a basic question—and it probably is. I am having trouble learning how to plot this function using meshgrid and surfc. I keep getting the error saying that "The surface Z must contain more than one row or column." Why am I getting this error? Here's what I have to do:

x = 0:.01:1;
y = 0:.01:1;
f = @(x, y) sin(4*pi.*x).*sin(y).*(1-y) + (1./sqrt(1+10.*(x.^2)+ 100.*(y-0.5).^2))
Z = f(x, y);
[X, Y] = meshgrid(x, y)
surfc(X, Y, Z)
surfcis complaining about the size ofZ. Check the sizes ofX,Y, andZusingsize(). Are they what you expect? And does that match the description of Z inhelp surfc? - Andrew Jankexandyyou're passing to thef()call. Are they also what you're expecting to be passing there, especially with respect to themeshgridcall? (Matlab is case sensitive.) - Andrew Janke