How to do surf plot if Z is not a matrix?
11 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Marta Salas
on 10 Mar 2014
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 Comment
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!