不同 z 维度的 x、y、z 数据的曲面图 MATLAB

问题描述 投票:0回答:1

我有以下数据:

M = 100; % [seconds]
D = 50; % number of masses
t = [0:dt:M];
y = randn(length(t),1); % [unitless] amplitude
z = [1:1:2*D]; % [unitless] number of eigenfrequencies
data = [t,y,z];

我想创建

data
的曲面图,其中 x 轴是
t
或时间,y 轴是
y
或幅度,z 轴是本征频率数。 x 和 y 数据的维度均为
t
,但 z 数据的维度为
2D
。是否可以使用维度与 MATLAB 中的 x 和 y 数据不同的 z 数据(使用
surf()
plot3()
)绘制 x、y、z 数据?

matlab plot multidimensional-array time-series surface
1个回答
0
投票

是的,您可以使用

plot3
来绘制它。要解决长度差异问题,请注意,您只需向
z
添加一个元素即可使其长度相同。

dt = 1;
M = 100; % [seconds]
D = 50; % number of masses
t = [0:dt:M];
y = randn(length(t),1); % [unitless] amplitude
z = [1:1:2*D+1]; % [unitless] number of eigenfrequencies

figure
plot3(t,y,z,'LineWidth', 2);
xlabel('t')
ylabel('y')
zlabel('z')

结果: enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.