在我的图中,我有两个轴,第一个是信号的时间序列,第二个是信号的时间序列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 运行幅度?
您需要提供更多输入参数spectrogram
。您需要的函数的形式是:
[S,F,T]=spectrogram(x,window,noverlap,F,fs)
See http://www.mathworks.com/help/signal/ref/spectrogram.html http://www.mathworks.com/help/signal/ref/spectrogram.html完整的文档,但基本上你需要定义:
-
windows
:用于每个频谱估计计算的样本数量
-
noverlap
:计算频谱 N-1 时要包含多少个样本
-
F
:您想要评估频谱的频率
-
fs
:信号的采样频率。
然后绘制频谱图:
subplot(313);
imagesc( T, F, log(S) ); %plot the log spectrum
set(gca,'YDir', 'normal'); % flip the Y Axis so lower frequencies are at the bottom
Note: The quality and 可解释性频谱图的分析取决于使用正确的输入spectrogram
功能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)