如何在2个频谱图之间进行减法,然后在MATLAB中绘制一个新的频谱图 [英] How to do subtraction between 2 spectrogram and then draw a new one in MATLAB

查看:413
本文介绍了如何在2个频谱图之间进行减法,然后在MATLAB中绘制一个新的频谱图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个频谱图的维数相同. 我尝试了S = spectrogram()来获取向量S,但是我不知道如何使用它回溯到频谱图.

The two spectrograms are in the same dimension. I tried S = spectrogram() to get the vector S, but I don't know how to draw back to spectrogram with it.

推荐答案

In the documentation, it says that the images are drawn with the command surf(T,F,10*log10(abs(P)));. So for example, you could plot the difference of two of these images with:

%# make some data
T = 0:0.001:2;
X1 = chirp(T,100,1,200,'q');
X2 = chirp(T,150,1,200,'q');

%# plot the first spectrogram
subplot(3,1,1);
spectrogram(X1,128,120,128,1E3);
title('Quadratic chirp 100Hz')

%# plot the second spectrogram
subplot(3,1,2);
spectrogram(X2,128,120,128,1E3);
title('Quadratic chirp 150Hz')

%# plot their difference
subplot(3,1,3);
[~,F1,T1,P1]=spectrogram(X1,128,120,128,1E3);
[~,F2,T2,P2]=spectrogram(X2,128,120,128,1E3);
%# just use the difference of the above two plot's z-values:
surf(T2,F2,10*(log10(abs(P2))-log10(abs(P1))),'edgecolor','none');
%# this is actually a 3D plot, so we set the viewing
%# angle as straight up and rotated by 90 to match the previous plots
view(90,-90);
axis tight;
title('Difference of Plots (2nd - 1st)')
ylabel('Freq (Hz)');
xlabel('Time');

此代码进行以下绘制:

这篇关于如何在2个频谱图之间进行减法,然后在MATLAB中绘制一个新的频谱图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆