[英]Matlab fft function
下面的代码来自Matlab 2011a关于fft函数的帮助。 我认为这里存在一个问题:为什么将t(1:50)乘以Fs,然后说是毫秒呢? 当然,这恰好是真正在这个非常特别的情况下,但改变Fs的价值,比方说,2000年,它将不再起作用, 右键的这一因素显然是因为? 误导了,不是吗? 我想念什么?
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)')
用这个更清晰:
fs = 2000; % Sampling frequency
T = 1 / fs; % Sample time
L = 1000; % Length of signal
t2 = (0:L-1)*T; % Time vector
f = 50; % signal frequency
s2 = sin(2*pi*f*t2);
figure, plot(fs*t2(1:50),s2(1:50)); % NOT good
figure, plot(t2(1:50),s2(1:50)); % good
你什么都不会错过。 这是一种典型的不良做法,即没有将单位用作每行的注释。 例如,
Fs=1000; % in [Hz]
T=1/Fs; % [sec]
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
然后,时间向量的单位为1/1000秒或毫秒...(每个元素为1毫秒)。 在其他情况下,Fs = 2000%[Hz],这使得时间向量具有1/2000秒的单位...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.