How to make surf plot have different x scales?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Voss
2023 年 11 月 19 日
% 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 件のコメント
Voss
2023 年 11 月 20 日
You're welcome!
The variable W I have defined is just some matrix I made up, since I don't have your W.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!