Plotting a function with 2 dependent variables
63 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a function a variable (z) which is dependent on two other variables (x,y). The function looks like z = f(x,y)
x ranges from 0 to 100 and y ranges from 0 to 1. I use linspace to divide both x and y into 100 values.Through nested loop substitution, I get 100 x 100 values for z.
How do I plot z against x and y? If I use plot3 I get an error saying dimensions don't match.
Thanks
0 个评论
采纳的回答
更多回答(1 个)
Mischa Kim
2021-1-7
Use meshgrid instead:
[x,y] = meshgrid(-10:0.1:10);
z = sin(x).*cos(y);
plot3(x,y,z)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!