<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 26/01/2013 17:00, constantina a
écrit :<br>
</div>
<blockquote cite="mid:1359216001776-4025764.post@n3.nabble.com"
type="cite">
<pre wrap="">Sorry, I know is a basic question, i now the answer in matlab but not in
scilab.... What is the function that let me find "peaks " in a matrix and
the position of the peaks??? </pre>
</blockquote>
Here is a possible solution, including peaks on the borders:<br>
<small><font face="Courier New, Courier, monospace"><br>
m = rand(6,6)<br>
M = [m(2,:) ; m ; m($-1,:) ];<br>
M = [M(:,2) M M(:,$-1)];<br>
pC = M(2:$-1,2:$-1)>M(1:$-2,2:$-1) &
M(2:$-1,2:$-1)>M(3:$,2:$-1);<br>
pR = M(2:$-1,2:$-1)>M(2:$-1,1:$-2) &
M(2:$-1,2:$-1)>M(2:$-1,3:$);<br>
isPeak = pC & pR<br>
find(isPeak) // returns linearized indices of peaks<br>
m(~isPeak) = 0 // to show only peaks<br>
</font></small><br>
giving:<br>
<br>
<small><font face="Courier New, Courier, monospace">-->m =
rand(6,6)<br>
m =<br>
0.0437334 0.7783129 0.8415518 0.5618661
0.3873779 0.2615761 <br>
0.4818509 0.2119030 0.4062025 0.5896177
0.9222899 0.4993494 <br>
0.2639556 0.1121355 0.4094825 0.6853980
0.9488184 0.2638578 <br>
0.4148104 0.6856896 0.8784126 0.8906225
0.3435337 0.5253563 <br>
0.2806498 0.1531217 0.1138360 0.5042213
0.3760119 0.5376230 <br>
0.1280058 0.6970851 0.1998338 0.3493615
0.7340941 0.1199926 <br>
<br>
-->M = [m(2,:) ; m ; m($-1,:) ];<br>
-->M = [M(:,2) M M(:,$-1)];<br>
-->pC = M(2:$-1,2:$-1)>M(1:$-2,2:$-1) &
M(2:$-1,2:$-1)>M(3:$,2:$-1);<br>
-->pR = M(2:$-1,2:$-1)>M(2:$-1,1:$-2) &
M(2:$-1,2:$-1)>M(2:$-1,3:$);<br>
-->isPeak = pC & pR<br>
isPeak =<br>
F F T F F F <br>
T F F F F F <br>
F F F F T F <br>
F F F T F F <br>
F F F F F T <br>
F T F F T F <br>
<br>
-->find(isPeak) // returns linearized indices of peaks<br>
ans =<br>
2. 12. 13. 22. 27. 30. 35. <br>
<br>
-->m(~isPeak) = 0 // to show only peaks<br>
m =<br>
0. 0. 0.8415518 0.
0. 0. <br>
0.4818509 0. 0. 0.
0. 0. <br>
0. 0. 0. 0.
0.9488184 0. <br>
0. 0. 0. 0.8906225
0. 0. <br>
0. 0. 0. 0.
0. 0.5376230 <br>
0. 0.6970851 0. 0.
0.7340941 0. <br>
<br>
<br>
</font><big>Regards<br>
Samuel<br>
</big><font face="Courier New, Courier, monospace"> <br>
</font></small><br>
</body>
</html>