How to find peaks in matrix the rest are 0
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
pzaksek
am 10 Jun. 2022
Kommentiert: pzaksek
am 11 Jun. 2022
Hello
Im asking for help. It's more complicated than I know about matlab ...
for clarification and explanation I use excel....
I have a data matrix (see picture). I would like to find different peakses. Other values becomes 0 (see picture 2).
thank you so much for the help
Peter
1 Kommentar
Dyuman Joshi
am 10 Jun. 2022
Please show proper data, without blue bubbles. Show the whole input data and the corresponding output data.
Akzeptierte Antwort
Dyuman Joshi
am 10 Jun. 2022
Run a double for loop through all the elements
A = randi(50,7,11) %sample matrix
B=zeros(size(A));
for i=1:size(A,1)
for j=1:size(A,2)
M = zeros(size(A));
M(i,j) = 1;
if all(A(i,j)>A(conv2(M,[1,1,1;1,0,1;1,1,1],'same')>0)) %checking if A(i,j) is local maxima
B(i,j)=A(i,j);
end
end
end
B
2 Kommentare
Weitere Antworten (2)
pzaksek
am 11 Jun. 2022
2 Kommentare
Dyuman Joshi
am 11 Jun. 2022
Please ask this as another question. (MATLAB Answers etiquette) In that way, others can also help you incase I can't.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!