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

Samuel Gougeon sgougeon at free.fr
Fri Mar 24 20:47:48 CET 2017


Hello Erhy,

Le 24/03/2017 à 20:36, Erhy a écrit :
> Hello!
> Again a basic question.
> e.g.
> A =  [ 1 2 3 ];
> I = find( A > 10);
> if length(I) > 0 then
> 	I = I + 1;
> end
>
> Is there a alternative
> *without the if ?*

Yes, just:
I = I + 1
The if is useless:

 1. length(I)==0 means I==[] and then I+1 == []+1 ==[]  as if nothing
    was done
 2. otherwise, just add 1

> I miss the .+ operator.

So do i, sometimes.

Samuel

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


More information about the users mailing list