简体   繁体   English

Matlab 3dplot函数绘制正弦曲线变化的频率和时间的幅度

[英]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: 这里有一些建议:

  • You probably want to replace combined(i,i2,i) = mag; 您可能要替换combined(i,i2,i) = mag; by combined(i,i2) = mag; 通过combined(i,i2) = mag; . That will create combined as a matrix (2D array) giving magnitude as a function of time and frequency 这将创建combined为矩阵(2D数组)的矩阵,其大小随时间和频率变化
  • To plot that, use something like surf or imagesc . 要进行绘制,请使用surfimagesc类的东西。
  • The code can be vectorized. 可以对代码进行矢量化处理。 This makes it more compact, arguably more readable, and faster. 这使其更紧凑,更易读,更快捷。
  • The figure changes significantly if you change 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. 您可能需要增加该参数。
  • You may want to avoid using 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.

相关问题 Matlab中3Dplot动画中点的绘制历史记录 - Drawing history of a point in a 3Dplot animation in Matlab MATLAB-查找与幅度相对应的传递函数的频率 - MATLAB - Find Frequency of Transfer Function Corresponding to a Magnitude 我试图在MATLAB中绘制复杂函数的大小 - Am trying to plot the magnitude of a complex function in MATLAB Matlab 3D传递函数幅度图 - Matlab 3D Plot of transfer function magnitude 如何使用MATLAB在指定的时间块中将已知频率插入具有不同频率的正弦曲线中 - How to insert a known frequency in a sinusoid with different frequencies at specified time chunk using MATLAB 如何绘制频率的幅度和相位? - How to plot the magnitude and phase of a frequency? 如何从时空图像的 MATLAB FFT2 输出中将时间频率绘制为空间频率的函数? - How to plot temporal frequency as a function of spatial frequency from a MATLAB FFT2 output of a time-space image? Matlab绘制对数啁啾的对数 - Matlab plot log magnitude of chirp 在Matlab中以不同频率播放赫兹音乐吗? - Playing a varying frequency in Hertz in matlab? 在幅度和相位方面进行频域傅立叶变换后,如何计算传递函数并将其绘制? - How to Calculate the transfer function and plot it after making fourier transform in frequency domain in terms of magnitude and phase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM