【发布时间】:2015-02-26 15:45:33
【问题描述】:
在下面发布的图片中,我尝试使用STFT 获取TFR。在发布的代码中,我指定了参数T = 0:.001:1;,当我将其修改为例如T = 0:.001:2; 时,绘图水平轴上的值范围发生了变化,尽管它被标记为Frequency。
现在,我想更改所示图上水平轴和垂直轴的值范围。我该怎么做?
注意:用于生成所示图的代码是:
T = 0:.001:1;
spectrogram(x4,128,50,NFFT);
代码:
% 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);
%two freqs. = abs(f1 - f2), that's why, x1 is plotted with 2 freqs.
x1 = (10)*sin(2*pi*30*t1);
x2 = (10)*sin(2*pi*60*t2) + x1;
x3 = (10)*sin(2*pi*90*t3) + x2;
x4 = (10)*sin(2*pi*120*t4) + x3;
%x5 = (10) * sin(2*pi*5*t5);
%x6 = x1 + x2 + x3 + x4 + x5;
NFFT = 2 ^ nextpow2(length(t)); % Next power of 2 from length of y
Y = fft(x3, 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(x4,10,9,31);
axis(get(gcf,'children'), [0, 1,0,100]);
% 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');
%plot(t5,x5,'y');
%plot(t, x6,'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');
图片
新结果_1
【问题讨论】:
-
@Schorsch 我发布了代码
-
如果我复制/粘贴该代码,它会告诉我
T没有被使用。更改T对情节没有影响。请考虑澄清您的问题。 -
0.967和1.0之间的白色“条纹”背后的问题是因为在您的代码中,您将第四个输入设置为spectrogram到31。但是,文档将其指定为the FFT length- 在您的情况下为8192。 -
@Schorsch 好的,在我的代码中我指定了“Y = fft(x4, NFFT);”在阅读了您的建议后,我将频谱图参数更改为“频谱图(x4,10,9,长度(y));”但是现在当我运行 matlab 时不接受这个参数
-
@Schorsch 好的,我解决了这个问题,我只是将没有“长度”的 NFFT 指定为频谱图的第四个参数
标签: matlab signal-processing fft wavelet haar-wavelet