Surf from a numerical array
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Voss
am 26 Feb. 2024
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 Kommentare
Voss
am 26 Feb. 2024
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
am 26 Feb. 2024
Verschoben: Voss
am 26 Feb. 2024
"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')
Weitere Antworten (1)
Sufiyan
am 26 Feb. 2024
I believe this is similar to changing the limits on the axis scale to different values or rescaling the axis.
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!