简体   繁体   中英

Plotting a 3d Function using Meshgrid and Surfc

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)

Got it:

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))


[X, Y] = meshgrid(x, y)
Z = f(X, Y);

size(x)
size(Y)
size(Z)
surfc(X, Y, Z)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM