⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mountainseek.m

📁 在阵列信号处理里
💻 M
字号:
%----------------------------------------------------
%---get the local max value for mutihump function---
%--------using mounting method-------
%---like small to large ,large to small----
%----------------------------------------------------
function [Pmax,Ind]=MountainSeek(P,num);
Pnum=length(P);
MouInd=zeros(1,Pnum);                                    %the index for mountains
P1=abs(P);                                                                              
k=1;
if P(1)>P(2)            MouInd(k)=1;k=k+1;end            
for i=2:Pnum-1
    if and(P1(i)>P1(i-1),P1(i)>P1(i+1)) MouInd(k)=i;k=k+1;end        
end                   
if P(Pnum)>P(Pnum-1)    MouInd(k)=Pnum;end                        

Temp_vec=find(MouInd>0);  
MouNum=length(Temp_vec);                                       
MouInd=MouInd(Temp_vec);
[P1,Temp_vec]=sort(P1(MouInd));                                      

Ind=MouInd(Temp_vec);                                                  
Ind=Ind(MouNum:-1:1);
Pmax=P(Ind);                    %sort the mountain value from large to small                                             

if nargin==2
    if num<MouNum
        Pmax=Pmax(1:num);              %get the max mountain of num
        Ind=Ind(1:num);
    end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -