[Scilab-users] add value to each element of an array, also to an empty one

Rafael Guerra jrafaelbguerra at hotmail.com
Fri Mar 24 23:53:16 CET 2017


An ugly alternative without find and without the if as requested:

A =  [ -1 2 7 ];

I = (A>10).*(cumsum(ones(A))+1);
I(I==0) = []
I  =
     []

I = (A>0).*(cumsum(ones(A))+1);
I(I==0) = []
I  =
    3.    4. 

Rgds,
Rafael



--
View this message in context: http://mailinglists.scilab.org/add-value-to-each-element-of-an-array-also-to-an-empty-one-tp4035989p4035996.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list