How to do surf plot if Z is not a matrix?
2 次查看(过去 30 天)
显示 更早的评论
I'm trying to make a 3-D surf plot but I'm not sure how I can acquire the Z value, because a is not defined and when I try to plug in numbers for a, and try to surf plot it, it says Z is not a matrix.
f(X,Y) = Z = 0.2 + sin(2*π*a*x)/(2*π*x) + sin(2*π*a*y)/(2*π*y)
HINT: Use the following code to set the range of x and y.
x=[-5:0.2:5]+eps; y=x; [X,Y]=meshgrid(x,y)
how can I make Z a matrix so I can use surf(X,Y,Z)
0 个评论
回答(1 个)
Marta Salas
2014-3-10
Let's assume a is a number. There is a value of Z for every (X,Y), thus, Z is a matrix and it has same size as X.
a = 1;
x=[-5:0.2:5]+eps;
y=x;
[X,Y]=meshgrid(x,y)
Z = 0.2 + sin(2*pi*a*X)./(2*pi*X) + sin(2*pi*a*Y)./(2*pi*Y);
figure, surf(X,Y,Z)
1 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!