Re: [Scilab-users] Strange behaviour with for loops

2015-09-30 Thread Samuel Gougeon

Hello Pierre,
Le 29/09/2015 16:20, Pierre Vuillemin a écrit :

Hello,
In the help, it is specified that the syntax 'for e = l ...' when l is 
a list is authorised. When l is replaced by a vector, the result 
appears to depend on whether its a column or row vector :

.../...
Is this behaviour intended?

.
Yes, and it is as well documented:
-->help for
"Description: .../... If expression is a matrix or a row vector, 
variable takes as values the values of each column of the matrix."


Samuel Gougeon

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange behaviour with for loops

2015-09-30 Thread Pierre Vuillemin

My bad, I was only focused on the list part of the help...

Thank you,

Pierre

Le 30.09.2015 09:50, Samuel Gougeon a écrit :

Hello Pierre,
Le 29/09/2015 16:20, Pierre Vuillemin a écrit :

Hello,
In the help, it is specified that the syntax 'for e = l ...' when l is 
a list is authorised. When l is replaced by a vector, the result 
appears to depend on whether its a column or row vector :

.../...
Is this behaviour intended?

.
Yes, and it is as well documented:
-->help for
"Description: .../... If expression is a matrix or a row vector,
variable takes as values the values of each column of the matrix."

Samuel Gougeon

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange behaviour with for loops

2015-09-30 Thread Dang, Christophe
Hello,

> De Samuel Gougeon
> Envoyé : mercredi 30 septembre 2015 09:51
>
> Le 29/09/2015 16:20, Pierre Vuillemin a écrit :
> >
> > Is this behaviour intended?
>
> Yes, and it is as well documented:

Hint: you can transform any matrix A into a line vector using
A(:)'

So in the present case, try the following code and see the difference

idx = [1 2 3]';
for i = idx(:)'
 disp("newIter")
 disp(i)
end

Hope this helps

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error), please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Strange behaviour with for loops

2015-09-29 Thread Pierre Vuillemin

Hello,

In the help, it is specified that the syntax 'for e = l ...' when l is a 
list is authorised. When l is replaced by a vector, the result appears 
to depend on whether its a column or row vector :


With this code, the for loops runs 3 times and each time i is equal to 
another value of the vector idx


idx =[1 2 3];
for i = idx
disp("newIter")
disp(i)
end

When the vector idx is a column vector now, there is only one loop and i 
is equal to the vector idx


idx = [1 2 3]';
for i = idx
disp("newIter")
disp(i)
end

Is this behaviour intended?


Pierre Vuillemin
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users