Surf from a numerical array
1 次查看(过去 30 天)
显示 更早的评论
Suppose I solve a PDE and obtain a solution in 2D say . If I do surf(u) I get a picture of the whole thing. Can I change the values of the axis to correspond to the actual values of interest? Currently the axis values just represent the number of data points, so I want to change that to actual values of interest.
0 个评论
采纳的回答
Voss
2024-2-26
Yes. You can use the xlim and ylim functions to set the axes limits to the actual region of interest.
Example:
% some matrix
z = peaks(100);
% the whole thing
figure();
surf(z)
xlabel('x')
ylabel('y')
zlabel('z')
% the actual region of interest
figure();
surf(z)
xlabel('x')
ylabel('y')
zlabel('z')
xlim([30 75])
ylim([50 90])
7 个评论
Voss
2024-2-26
Not necessarily. In surf(X,Y,Z) X and Y can be vectors or matrices.
meshgrid would be useful for constructing matrix X and Y from vector X and Y, but you can use the vectors directly in surf.
Voss
2024-2-26
移动:Voss
2024-2-26
"Currently the axis values just represent the number of data points, so I want to change that to actual values of interest."
Specify the values of interest in the call to surf.
Example:
% 10 t values ranging from 0.01 to 0.02
t = linspace(0.01,0.02,10)
% 15 x values ranging from 100 to 200
x = linspace(100,200,15)
% 15-by-10 matrix u
u = exp(t.*x.')
% plot the surface
surf(t,x,u)
xlabel('t')
ylabel('x')
zlabel('u')
更多回答(1 个)
Sufiyan
2024-2-26
I believe this is similar to changing the limits on the axis scale to different values or rescaling the axis.
另请参阅
类别
在 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!