在下面发布的图片中,我正在尝试TFR
使用STFT
. 在发布的代码中,我指定了参数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