-2

我在代码中定义了四个非平稳信号的频率分量,如下所示。当我试图绘制这些信号的频域时,我得到了一个只有三个频率峰值的图表,如下图所示。?!

请让我知道为什么我只有三个峰值,而我有四个频率。成分。

代码

% Time specifications:
Fs = 8000;                       % samples per second
dt = 1/Fs;                       % seconds per sample
StopTime = 2;                    % seconds
t = (0:dt:StopTime-dt);             % seconds

t1 = (0:dt:.25);
t2 = (.25:dt:.50);
t3 = (.5:dt:.75);
t4 = (.75:dt:1);

x1 = (10)*sin(2*pi*10*t1);
x2 = (10)*sin(2*pi*20*t2) + x1;
x3 = (10)*sin(2*pi*50*t3) + x2;
x4 = (10)*sin(2*pi*70*t4) + x3;

NFFT  = 2 ^ nextpow2(length(t));     % Next power of 2 from length of y
Y    = fft(x4, NFFT);
f    = Fs / 2 * linspace(0, 1, NFFT/2 + 1);
figure;
plot(f(1:200), 2 * abs( Y( 1:200) ) );

% Plot the signal versus time:
figure;
xlabel('time (in seconds)');
ylabel('Amplitude');
title('non-stationary Signal versus Time');

hold on
plot(t1,x1,'r');
plot(t2,x2,'g');
plot(t3,x3,'b');
 plot(t4,x4,'black');
  legend('x1 = (10)*sin(2*pi*15*t1) + (10)*sin(2*pi*8*t1)', 'x2 = (10)*sin(2*pi*25*t2)   
 +    
 x1', 'x3 = (10)*sin(2*pi*50*t3) + x2', 'x4 = (10)*sin(2*pi*75*t4) + x3', ...
'Location',  'SouthWest');

图片 ::在此处输入图像描述

4

1 回答 1

0

您已经绘制了 x3 的 fft,它只是前三个信号的总和。我认为您打算为 x4 绘制此图,其中包括第四个信号。

于 2015-01-01T13:07:47.680 回答