Surf from a numerical array
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Voss
el 26 de Feb. de 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 comentarios
Voss
el 26 de Feb. de 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
el 26 de Feb. de 2024
Movida: Voss
el 26 de Feb. de 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')
Más respuestas (1)
Sufiyan
el 26 de Feb. de 2024
I believe this is similar to changing the limits on the axis scale to different values or rescaling the axis.
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


