首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在MATLAB中对两个谱图进行减法运算,然后绘制新的谱图

如何在MATLAB中对两个谱图进行减法运算,然后绘制新的谱图
EN

Stack Overflow用户
提问于 2012-02-25 20:10:13
回答 1查看 1.9K关注 0票数 1

这两个光谱图在同一维度上。我试着用S = spectrogram()得到向量S,但我不知道如何用它来绘制光谱图。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-25 22:56:24

documentation中,它说明图像是使用命令surf(T,F,10*log10(abs(P)));绘制的。例如,您可以使用以下命令绘制其中两个图像的差异:

代码语言:javascript
复制
%# 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');

这段代码绘制了以下图:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9443854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档