Surf or Mesh plot

7 ビュー (過去 30 日間)
Mir Khadim Aalam
Mir Khadim Aalam 2022 年 4 月 19 日
コメント済み: Star Strider 2022 年 4 月 20 日
I have a matrix "A" of size =5100*34 and another vector "t" of size 5100*1, I want to plot both using the surf or mesh command, with "t" as x-axis, and the column vectors of "A" i.e 5100*1 samples as Z-axis and the 34 (1:1:34) as the y-axis. I am facing some problems with this, any help will be very useful.

採用された回答

Star Strider
Star Strider 2022 年 4 月 19 日
Since ‘z’ must be a matrix to use surf or mesh, the call must be:
t = linspace(0, 5100, 5100);
y = linspace(0, 34, 34);
z = t(:) * sin(3*pi*y/numel(y));
figure
surf(t, y, z.', 'EdgeColor','none')
grid on
xlabel('t')
ylabel('y')
colormap(turbo)
The ‘z’ matrix must be transposed for this to work as you described.
.
  2 件のコメント
Mir Khadim Aalam
Mir Khadim Aalam 2022 年 4 月 20 日
It helped, Thanks a lot.
Star Strider
Star Strider 2022 年 4 月 20 日
As always, my pleaure!

サインインしてコメントする。

その他の回答 (1 件)

Davide Masiello
Davide Masiello 2022 年 4 月 19 日
Try this
clear,clc
t = linspace(0,100,5100);
y = 1:34;
[t,y] = meshgrid(t,y);
A = 2./(t+1)+y.^2;
surf(t,y,A,'EdgeColor','none')

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by