Apply 'findpeaks' in every column
이전 댓글 표시
Hi guys, i have a problem.
I have a (1200x600) matrix, where each column consists on a trace with at least 3 peaks, and i want to find the 3 maxpeaks in every column.
For the first trace (first column) the following code gives me the 3 max values:
Pilant_Vy_env = xlsread('Pilant_Vy_env.xlsx'); %The matrix is in .xlsx matlab spreadsheet format
first = Pilant_Vy_env(:,1);
[PKS,locs,~,prm] = findpeaks(first); %'first' is the first column of the matrix
[~,i] = sort(prm,'descend');
MAX = first(locs(i(1:3)));
plot(1:numel(first),first,'-',locs(i(1:3)),MAX,'o ')
What should i do if i want to use it for all the others 599 columns?
Thank you for your kind consideration,
Mattia
답변 (1개)
ncol=size(Pilant_Vy_env,2);
MAX = zeros(ncol,3) ;
for k = 1:ncol
[PKS,locs,~,prm] = findpeaks(Pilant_Vy_env(:,k));
[~,j] = sort(prm,'descend');
MAX(k,:) = first(locs(j(1:3)));
end
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

