[scilab-Users] vector elementwise division 1./[1 2 3 4]

Antoine ELIAS antoine.elias at scilab.org
Tue Sep 2 10:59:31 CEST 2008


Hi Bagvian,

Yes it's strange but "normal' :D
Scilab's parser tries to interpret "1." and after "/V1"
So for Scilab you try to divide 1.0 ( floating point value ) by V1 ( not 
element wise )
To be sure Scilab use "./" operator, add spaces around operator like "1 
./ V1"

Regards,
Antoine ELIAS

bagvian a écrit :
> Hi,
>
> Old Matlab user, I wanted to create a simple row vector (say V1) and
> inverse each of its components with the values to be set in another
> row vector (say V2). I typed in Scilab prompt:
>
> V1=[1 2 3 4] ;
>
> V2=1./V1
>
> I obtained :
>
> V2 =
>
> 0.0333333
>
> 0.0666667
>
> 0.1
>
> 0.1333333
>
> Amazing, isn't?
>
> In order to get the result I expected, I had to type :
>
> V2=(1)./V1
>
> To obtain:
>
> V2 =
>
> 1. 0.5 0.3333333 0.25
>
> Don't you find this behaviour rather inappropriate?
>
> Thanks for your comments, Bagvian
>   




More information about the users mailing list