MATLAB中峰数的确定
我试图在Matlab中找到峰值的数量。当我根据我的阈值绘制给定的wav文件时,我可以很容易地看到有两个不同的峰值。但是我怎么能在屏幕上写“有两个峰”?这是我的第一次尝试:MATLAB中峰数的确定,matlab,Matlab,我试图在Matlab中找到峰值的数量。当我根据我的阈值绘制给定的wav文件时,我可以很容易地看到有两个不同的峰值。但是我怎么能在屏幕上写“有两个峰”?这是我的第一次尝试: hfile = 'two.wav'; [stereo1, Fs, nbits, readinfo] = wavread(hfile); mono1 = mean(stereo1,2); M = round(0.01*Fs); N = 2^nextpow2(4*M); w = gausswin(M); [S,F,T,P
hfile = 'two.wav';
[stereo1, Fs, nbits, readinfo] = wavread(hfile);
mono1 = mean(stereo1,2);
M = round(0.01*Fs);
N = 2^nextpow2(4*M);
w = gausswin(M);
[S,F,T,P] = spectrogram(mono1,w,120,N,Fs);
thresh_l=1000;
thresh_h=10000000;
% take the segment of P relating to your frequencies of interest
P2 = P(F>thresh_l&F<thresh_h,:);
%show the mean power in that band over time
m = mean(P2);
[pks,loc]=findpeaks(T,'npeaks',m);
message = sprintf('The number of peaks found = %d',length(pks));
msgbox(message);
hfile='two.wav';
[stereo1,Fs,nbits,readinfo]=wavread(hfile);
mono1=平均值(1,2);
M=圆形(0.01*Fs);
N=2^nextpow2(4*M);
w=高斯(M);
[S,F,T,P]=谱图(mono1,w,120,N,Fs);
thresh_l=1000;
阈值h=10000000;
%取与你感兴趣的频率相关的P段
P2=P(F>thresh\u l&F寻找一阶导数的符号位置如何?假设x是你的时间序列
dx = diff(x);
% need to add 1 b/c of the offset generated by diff
peak_loc = find((dx(1:end - 1) > 0) & (dx(2:end) <= 0)) + 1;
peak_num = len(peak_loc);
dx=diff(x);
%需要将差异产生的偏移量增加1个b/c
peak_loc=find((dx(1:end-1)>0)和(dx(2:end)在屏幕上的什么位置?在弹出的msgbox中或作为绘图本身的注释?两者都可以。您可以添加一些可以编写此消息的代码吗?非常感谢,但如何将此代码块集成到现有代码中?我已经尝试过,但没有找到任何峰值?