How to find seven peaks in matrix 8192X8192?

3 visualizaciones (últimos 30 días)
Daniel Fonsêca
Daniel Fonsêca el 20 de Sept. de 2018
Editada: jonas el 20 de Sept. de 2018
Hello! I'm trying to find the seven tallest peaks from a matrix whose dimension is 8192X8192. I'm using the following programm:
function [h,hs,w,ws]=la(MC)
for i=1:1024 %laço para determinar os picos e comprimentos dos picos
[pks{i},w{i}] = findpeaks(MC(i,:)); %'findpeaks' função que indica os picos e comprimentos dos picos.
% ATENÇÃO: Só dá para fazer isso usando cell array.
end
hs = cell2mat(pks);%Função que armazena um vetor oriundo da converção do cell array para double.
ws = cell2mat(w);%Função que armazena um vetor oriundo da converção do cell array para double.
k =size(hs);%Dimensão do vetor hs. Será usado mais a frente nos próximos laços.
h = zeros(40,1);%Valor que armazenará a maior altura realizado pela comparação.
in = zeros(40,1);%Armazenará o indice da maior altura.
b=0;
for i=1:k(1,2)% for de comparação
if 1000<hs(1,i)%Comparação
b=b+1;
h(b,1) = hs(1,i);
in(b,1) = i;
end
end
With the function findpeaks, I find too many peaks. I've thougth use the seven tallest peaks, what dou you think?

Respuesta aceptada

jonas
jonas el 20 de Sept. de 2018
Editada: jonas el 20 de Sept. de 2018
What do you mean highest peaks? Highest prominence? Highest peak value?
The syntax of findpeaks is the following:
[Peaks,Locs,Width,Prom]=findpeaks(x)
The output variables store the peak values, their index, their width and their prominence. Let's say you find n>7 peaks, but you are only interested in the 7 tallest ones, based on their peak value. Let's extract those
[nPeaks,id]=maxk(peaks,7)
and their locations
[nLocs]=Locs(id)
Simple as that. If you are interested in the maximum prominence, just adjust the code accordingly.

Más respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by