How to make surf plot have different x scales?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi there,
I have plotted a 2D graph using the surf(x,t,w) function first and then using the view(2) commend. The W is a 2000x11matrix. x denotes space and is the 1x11 vector. t denotes time and is the 1x2000 vector. Now I want to rescale space x. For each time t, x is rescaled differently. For example, when t=t_1, x is rescaled to 1.2x (each element in the vector x is multiplied by 1.2); when t=t_2, x is rescaled to 1.5x (each element in the vector x is multiplied by 1.5); and so on. How can I achieve this? Any help would be appreciated! Attached is the graph I get.
0 comentarios
Respuesta aceptada
Voss
el 19 de Nov. de 2023
% define t,x,W variables:
Nx = 11;
Nt = 2000;
W = (Nx:-1:1).*(Nt:-1:1).'/4500;
t = linspace(0,200,Nt);
x = linspace(0,1,Nx)
% plot original:
figure
surf(x,t,W,'EdgeColor','none')
view(2)
xlabel('x')
ylabel('t')
colormap(jet())
colorbar
title('original')
% generate factors to multiply x by, one for each element of t:
x_factor = 1.2+0.3*(0:Nt-1) % 1.2, 1.5, and so on
% make matrices called tt (from t) and xx (from x and x_factors)
% t gets replicated:
tt = repmat(t(:),1,Nx);
% x gets multiplied by the factors:
xx = x.*x_factor(:)
% plot rescaled result:
figure
surf(xx,tt,W,'EdgeColor','none')
view(2)
xlabel('x')
ylabel('t')
colormap(jet())
colorbar
title('rescaled')
2 comentarios
Voss
el 20 de Nov. de 2023
You're welcome!
The variable W I have defined is just some matrix I made up, since I don't have your W.
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D 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!