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-valu
Samuel GOUGEON wrote
> Not in Scilab 6, for the time being. I assumed that you were using Scilab
> 6.
so I will jump to version 6
Thank you!
--
View this message in context:
http://mailinglists.scilab.org/add-value-to-each-element-of-an-array-also-to-an-empty-one-tp4035989p4035993.html
Sent f
Le 24/03/2017 à 21:08, Erhy a écrit :
Samuel GOUGEON wrote
1. length(I)==0 means I==[] and then I+1 == []+1 ==[] as if nothing
But in my examples
I = [];
Iplus = I + 1;
then Iplus is 1
Not in Scilab 6, for the time being. I assumed that you were using Scilab 6.
In Scilab 5: i know nothing s
Samuel GOUGEON wrote
> 1. length(I)==0 means I==[] and then I+1 == []+1 ==[] as if nothing
But in my examples
I = [];
Iplus = I + 1;
then Iplus is 1
--
View this message in context:
http://mailinglists.scilab.org/add-value-to-each-element-of-an-array-also-to-an-empty-one-tp4035989p4035991.h
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 ==
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 ?*
I miss the .+ operator.
Thank you
--
View this message in context:
http://mailinglists.scilab.org/add-value-to-each-element-of-an-ar