我正在尝试创建一个3d图,以显示添加3个不同相位的正弦曲线的幅度。三个轴将是:时间,频率和幅度。我只是不确定如何将我所拥有的内容转换为3dplot函数可以使用的内容。新的,谢谢!
clear;
clc;
inc = 100;
i = 1;
i2 = 1;
for t = 0:(2.413E-9)/inc:2.413E-9 %time range to view signals
for f = 56E9:(64E9-56E9)/inc:64E9 %frequencies from 56ghz - 64ghz
w = 2*pi*f;
wave1 = 0.5*sin(w.*t + (0.25*2));%sinusoids of varying distances, arbitrary amplitude
wave2 = 0.5*sin(w.*t);
wave3 = 0.5*sin(w.*t - (0.25*2));
mag = wave1 + wave2 + wave3;%combining waves
combined(i,i2,i) = mag;
%f,time,magnitude
i = i + 1;%changing frequency index
end
i = 1;
i2 = i2 + 1;%changing time index
end
编辑:谢谢大家,我想我有我想要的东西。
答案 0 :(得分:0)
以下是一些建议:
combined(i,i2,i) = mag;
替换为combined(i,i2) = mag;
。这将创建combined
作为矩阵(2D阵列),给出作为时间和频率函数的幅度surf
或imagesc
。inc
,则数字会发生显着变化。这可能表示当前inc
在表示中导致aliasing。您可能希望增加该参数。i
作为变量名称。代码:
clear;
clc;
inc = 100;
t = 0:(2.413E-9)/inc:2.413E-9; %time range to view signals
f = 56E9:(64E9-56E9)/inc:64E9 %frequencies from 56ghz - 64ghz
w = 2*pi*f;
wave1 = 0.5*sin(bsxfun(@times, w.', t) + (0.25*2));%sinusoidsdistances
wave2 = 0.5*sin(bsxfun(@times, w.', t));
wave3 = 0.5*sin(bsxfun(@times, w.', t) - (0.25*2));
combined = wave1 + wave2 + wave3;%combining waves
%f,time,magnitude
surf(t, f, combined, 'edgecolor', 'none')
xlabel time
ylabel frequency