Plot函数中的参数

时间:2013-02-08 10:13:18

标签: matlab

以下Matlab脚本(取自fft的MATLAB帮助)运行完全正常

Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 1000;                     % Length of signal
t = (0:L-1)*T;                % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); 
y = x + 2*randn(size(t));     % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')

enter image description here

但是我无法理解为什么我们需要在plot()中使用Fs * t。为什么我要减少尺寸?

1 个答案:

答案 0 :(得分:2)

您的向量t是根据样本定义的,即t(10)是作为第10个样本的值。

如果要绘制信号与时间的关系,则必须将采样实例与采样时间相乘,即time = FS*t

如果您不进行缩放,最终会绘制信号与采样实例的关系。然而,标签"时间(ms)"是不正确的。

相关问题