0

我想知道spectrogram下面发布的是否是给定非平稳信号的真实表示。

如果这是一个真实的表示,我对情节中的特定特征有很多疑问......

对于水平轴上的 0->.25,为什么它显示最高频率的信号分量?我假设,给定第一个持续时间t1,我应该只看到信号的频率x1。此外,给定第二个持续时间t2,我应该只看到信号的频率x2,依此类推。但是,这不是我在下面发布的内容中看到的spectrogram

您能否解释一下为什么我们会在频谱图中看到这些特征?

带有方程的频谱图 在此处输入图像描述

代码

% Time specifications:
Fs = 8000;                       % samples per second
dt = 1/Fs;                       % seconds per sample
StopTime = 1;                    % 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*30*t3) + x2;
x4 = (10)*sin(2*pi*40*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) ) );
%}

 T = 0:.01:1;
 spectrogram(x4,10,9,NFFT);
 ylabel('Frequency');
 axis(get(gcf,'children'), [0, 1, 1, 50]);

Update_1:当我尝试建议的答案时,我收到了以下信息。

??? Out of memory. Type HELP MEMORY for your options.
Error in ==> spectrogram at 168
y = y(1:length(f),:);
Error in ==> stft_1 at 36
spectrogram(x,10,9,NFFT);

使用的代码:

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

%get a full-length example of each signal component
x1 = (10)*sin(2*pi*10*t);
x2 = (10)*sin(2*pi*20*t);
x3 = (10)*sin(2*pi*30*t);
x4 = (10)*sin(2*pi*40*t);

%construct a composite signal
x = zeros(size(t));
I = find((t >= t1(1)) & (t <= t1(end)));
x(I) = x1(I);
I = find((t >= t2(1)) & (t <= t2(end)));
x(I) = x2(I);
I = find((t >= t3(1)) & (t <= t3(end)));
x(I) = x3(I);
I = find((t >= t4(1)) & (t <= t4(end)));
x(I) = x4(I);

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

T = 0:.01:1;
spectrogram(x,10,9,NFFT);
ylabel('Frequency');
  axis(get(gcf,'children'), [0, 1, 1, 50]);

更新_2

% Time specifications:
Fs = 8000;                       % samples per second
dt = 1/Fs;                       % seconds per sample
 StopTime = 1;                    % seconds
  t = (0:dt:StopTime-dt);             % seconds
  t1 = ( 0:dt:.25);
  t2 = (.25:dt:.50);
  t3 = (.5:dt:.75);
  t4 = (.75:dt:1);

  %get a  full-length example of each signal component
 x1 = (10)*sin(2*pi*100*t);
 x2 = (10)*sin(2*pi*200*t);
 x3 = (10)*sin(2*pi*300*t);
 x4 = (10)*sin(2*pi*400*t);

 %construct a composite signal
 x = zeros(size(t));
 I = find((t >= t1(1)) & (t <= t1(end)));
 x(I) = x1(I);
 I = find((t >= t2(1)) & (t <= t2(end)));
 x(I) = x2(I);
 I = find((t >= t3(1)) & (t <= t3(end)));
 x(I) = x3(I);
 I = find((t >= t4(1)) & (t <= t4(end)));
 x(I) = x4(I);

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

 T = 0:.001:1;
 spectrogram(x,10,9);
 ylabel('Frequency');
 axis(get(gcf,'children'), [0, 1, 1, 100]);

谱图_2在此处输入图像描述

4

1 回答 1

1

我不认为你正在策划你认为你正在策划的事情。您应该在时域中绘制信号以确保它看起来像您期望的那样plot(x4)...... 我认为您认为您的信号是 x1,然后是 x2,然后是 x3,然后是 x4。但是,根据您展示的 Matlab 代码,情况并非如此。

相反,您的信号是 x1+x2+x3+x4 的总和。因此,由于信号的瞬态启动,您应该看到 10、20、30、40 Hz 的信号分量以及其他分量。

要获得所需的信号,您应该执行以下操作:

%get a full-length example of each signal component
t = (0:dt:StopTime-dt);
x1 = (10)*sin(2*pi*10*t);
x2 = (10)*sin(2*pi*20*t);
x3 = (10)*sin(2*pi*30*t);
x4 = (10)*sin(2*pi*40*t);

%construct a composite signal from the four signals above
x = zeros(size(t)); %allocate an empty vector of the correct size
I = find((t >= t1(1)) & (t <= t1(end)));
x(I) = x1(I);
I = find((t >= t2(1)) & (t <= t2(end)));
x(I) = x2(I);
I = find((t >= t3(1)) & (t <= t3(end)));
x(I) = x3(I);
I = find((t >= t4(1)) & (t <= t4(end)));
x(I) = x4(I);

然后,您可以x在时域 ( plot(x)) 中绘制新信号,以确保它是您想要的。最后,您可以执行您的spectrogram.

请注意,您将在每个时间段之间(在 t1 和 t2 之间、在 t2 和 t3 之间,然后在 t3 和 t4 之间)之间的转换中看到频谱图中的伪影。信号伪影将反映在不同信号频率之间的不连续过渡期间信号是复杂的。

于 2014-12-31T02:08:49.113 回答