[Scilab-users] surf and %nan

Rafael Guerra jrafaelbguerra at hotmail.com
Tue Nov 21 21:06:26 CET 2017


For the task requested the same M results are obtained with either syntax:


x=1:100;
y=1:200;
M= x.*.y';
M(10,11:99)=-999;
M(13,13)=-999;
M2 = M;

[a,b]=find(M==-999);
M(a,b) = %nan;

M2(M2==-999)= %nan;


-->max(M2-M)

 ans  =

    0.



-->min(M2-M)

 ans  =

    0.





-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of sgougeon at free.fr
Sent: Tuesday, November 21, 2017 8:41 PM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] surf and %nan



>It is not the most compact form but I think there is no issue with original syntax proposed:

>[a,b]=find(M==-999);

>M(a,b) = %nan;



In the M(a,b) syntax, a stands for the indices of selected ROWS, and b for the vector of selected COLUMNS, no matter about the fact that a and b have here the same length and then could be -- erroneously -- considered as respective elementwise indices.

This is why linearized indices must be used, as returned by i = find(..).



--> m = int8(grand(5,5,"uin",0,9))

m  =

  2  1  5  0  9

  2  9  5  9  9

  4  5  0  4  3

  5  8  6  7  9

  4  3  9  6  6



--> m([2 3 5],[1 2 4])

ans  =

  2  9  9

  4  5  4

  4  3  6



--> m([2 3 5]',[1 2 4]')

ans  =

  2  9  9

  4  5  4

  4  3  6



BR


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20171121/ee6626b2/attachment.htm>


More information about the users mailing list