[英]Matlab 3dplot function to plot magnitude of a sinusoid varying frequency and time
I'm trying to create a 3d plot to show the amplitude of adding 3 sinusoids of varying phase. 我正在尝试创建一个3D图,以显示相加3个正弦波的幅度。 The three axes would be: time, frequency and magnitude.
三个轴将是:时间,频率和幅度。 I'm just not sure how I can convert what I have into something that the function 3dplot can use.
我只是不确定如何将自己拥有的东西转换为3dplot函数可以使用的东西。 New to this, thanks!
这是新手,谢谢!
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
EDIT: Thanks everyone, I think I have what I was looking for. 编辑:谢谢大家,我想我有想要的东西。
Here are some suggestions: 这里有一些建议:
combined(i,i2,i) = mag;
combined(i,i2,i) = mag;
by combined(i,i2) = mag;
combined(i,i2) = mag;
. combined
as a matrix (2D array) giving magnitude as a function of time and frequency combined
为矩阵(2D数组)的矩阵,其大小随时间和频率变化 surf
or imagesc
. surf
或imagesc
类的东西。 inc
. inc
该数字将发生显着变化。 This may be a sign that the current inc
is causing aliasing in the representation. inc
正在引起表示中的混淆 。 You may want to increase that parameter. i
as variable name. i
用作变量名。 Code: 码:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.