Info
此问题已关闭。 请重新打开它进行编辑或回答。
Find the interval of an envelope corresponding to a specific peak after peak detection
1 次查看(过去 30 天)
显示 更早的评论
I have done the peak detection to find the highest peak in the image below. How do I find the interval of the envelope corresponding to that peak?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208938/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208938/image.jpeg)
0 个评论
回答(1 个)
KSSV
2019-3-18
Let (x,y) be your data.
[val,idx] = max(y) ;
x_max = x(idx) ;
y_max = y ;
Read about max
10 个评论
KSSV
2019-3-18
load('peak_data.mat') ;
y = MDL_1_env_norm ;
x = 1:length(y) ;
%
threshold = 0.01 ;
x1 = x ;
y1 = y ;
y1(y>threshold) = NaN ;
x1(isnan(y1)) = 0 ;
% Seeprate nans seperately
ii = zeros(size(x1));
jj = x1 > 0;
ii(strfind([0,jj(:)'],[0 1])) = 1;
idx = cumsum(ii).*jj;
out = accumarray( idx(jj)',x1(jj)',[],@(x){x'});
idx0 = out{1}(end) ;
idx1 = out{2}(1) ;
idx2 = out{2}(end) ;
idx3 = out{3}(1) ;
idx = [idx0 idx1 idx1 idx2 idx3] ;
plot(x,y,'r') ;
hold on
plot(x(idx),y(idx),'*b') ;
![untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208962/untitled.png)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!