Surf from a numerical array
3 ビュー (過去 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!


