在我的图形中,我有两个轴,第一个是信号的时间序列,第二个是信号的ifft
。我想添加第三个轴,其中包含信号的频谱图。我该如何做?
% Create the raw signal
fs = 40;
t = 0:( 1/fs ):4;
y1 = [ sin( 2*pi*5*t( t<=2 ) ), sin( 2*pi*10*t( t>2 ) ) ];
% Compute the ifft of the signal
Fy1 = abs(ifft(y1));
N = numel(t);
idx = 1:numel(Fy1) / 2;
f = fs*(0:(N-1)) / N;
% Plot the raw signal as a time series
subplot(311);
plot(t,y1,'k');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot the spectrum of the signal
subplot(312);
plot(f(idx),2*Fy1(idx),'k')
xlabel('Frequency (cycles/second)');
ylabel('Amplitude');
我尝试使用spectrogram
函数,但我很难将其结果解释为图形。如何计算声谱图,使得时间沿x轴运行,幅度沿y轴?