How to find seven peaks in matrix 8192X8192?

1 次查看(过去 30 天)
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?

采纳的回答

jonas
jonas 2018-9-20
编辑:jonas 2018-9-20
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.

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by