Apply 'findpeaks' in every column
Afficher commentaires plus anciens
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
Réponses (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
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

