Kat*_*tyB 5 matlab spectrogram
在我的图中,我有2个轴,第一个是信号的时间序列,第二个是信号的时间序列ifft.我想添加一个包含信号频谱图的第3轴.我怎样才能做到这一点?
% 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');
Run Code Online (Sandbox Code Playgroud)
我已经尝试过使用该spectrogram功能但是我很难将其结果解释为数字.如何计算频谱图,以便沿着x轴运行时间和沿y运行的幅度?
您需要提供更多输入参数spectrogram.您需要的功能形式是:
[S,F,T]=spectrogram(x,window,noverlap,F,fs)
Run Code Online (Sandbox Code Playgroud)
请参阅http://www.mathworks.com/help/signal/ref/spectrogram.html完整文档,但基本上您需要定义:
windows:用于每个谱估计计算的样本数noverlap:从频谱N中的频谱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
Run Code Online (Sandbox Code Playgroud)
注意:频谱图的质量和可解释性取决于在spectrogram函数中使用正确的输入.
| 归档时间: |
|
| 查看次数: |
22791 次 |
| 最近记录: |