[Scilab-users] Peaks and positions
Stefan Du Rietz
sdr at durietz.se
Mon Jan 28 22:35:32 CET 2013
It means the last element of the vector/matrix.
/Stefan
On 2013-01-28 22:30, Berns Buenaobra wrote:
--------------------
> Hi Samuel:
>
> I'd like to understand the "$" inside the would mean from the script?
>
> Thanks,
> Berns B.
>
>
> On Sun, Jan 27, 2013 at 12:46 AM, Samuel Gougeon <sgougeon at free.fr
> <mailto:sgougeon at free.fr>> wrote:
>
> Le 26/01/2013 17:00, constantina a écrit :
>> 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???
> Here is a possible solution, including peaks on the borders:
>
> m = rand(6,6)
> M = [m(2,:) ; m ; m($-1,:) ];
> M = [M(:,2) M M(:,$-1)];
> pC = M(2:$-1,2:$-1)>M(1:$-2,2:$-1) & M(2:$-1,2:$-1)>M(3:$,2:$-1);
> pR = M(2:$-1,2:$-1)>M(2:$-1,1:$-2) & M(2:$-1,2:$-1)>M(2:$-1,3:$);
> isPeak = pC & pR
> find(isPeak) // returns linearized indices of peaks
> m(~isPeak) = 0 // to show only peaks
>
> giving:
>
> -->m = rand(6,6)
> m =
> 0.0437334 0.7783129 0.8415518 0.5618661 0.3873779
> 0.2615761
> 0.4818509 0.2119030 0.4062025 0.5896177 0.9222899
> 0.4993494
> 0.2639556 0.1121355 0.4094825 0.6853980 0.9488184
> 0.2638578
> 0.4148104 0.6856896 0.8784126 0.8906225 0.3435337
> 0.5253563
> 0.2806498 0.1531217 0.1138360 0.5042213 0.3760119
> 0.5376230
> 0.1280058 0.6970851 0.1998338 0.3493615 0.7340941
> 0.1199926
>
> -->M = [m(2,:) ; m ; m($-1,:) ];
> -->M = [M(:,2) M M(:,$-1)];
> -->pC = M(2:$-1,2:$-1)>M(1:$-2,2:$-1) & M(2:$-1,2:$-1)>M(3:$,2:$-1);
> -->pR = M(2:$-1,2:$-1)>M(2:$-1,1:$-2) & M(2:$-1,2:$-1)>M(2:$-1,3:$);
> -->isPeak = pC & pR
> isPeak =
> F F T F F F
> T F F F F F
> F F F F T F
> F F F T F F
> F F F F F T
> F T F F T F
>
> -->find(isPeak) // returns linearized indices of peaks
> ans =
> 2. 12. 13. 22. 27. 30. 35.
>
> -->m(~isPeak) = 0 // to show only peaks
> m =
> 0. 0. 0.8415518 0. 0. 0.
> 0.4818509 0. 0. 0. 0. 0.
> 0. 0. 0. 0. 0.9488184 0.
> 0. 0. 0. 0.8906225 0. 0.
> 0. 0. 0. 0. 0. 0.5376230
> 0. 0.6970851 0. 0. 0.7340941 0.
>
>
> Regards
> Samuel
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org <mailto:users at lists.scilab.org>
> http://lists.scilab.org/mailman/listinfo/users
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
More information about the users
mailing list