How to find seven peaks in matrix 8192X8192?

조회 수: 3 (최근 30일)
Daniel Fonsêca
Daniel Fonsêca 2018년 9월 20일
편집: jonas 2018년 9월 20일
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개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by