Я хочу знать, является ли 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]);
Обновление_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]);
Dpectrogram_2: