[scilab-Users] Another beginner question

Collette yann yann.collette at scilab.org
Thu Nov 12 08:59:41 CET 2009


Sébastien Bihorel a écrit :
> Hi,
>
> While translating some Matlab to Scilab, I stumbled upon some issues 
> with problems with the eval function. I don't quite get why the 'eval 
> 6' statement of the following code returns an error (and not the 'eval 
> 3' statement), and would appreciate any explanation.
>
> Thank you
>
> Sebastien
>
>
> function [b]=test(z)
>   b = 1;  
> endfunction
>
> function [x,y]=test2(z)
>   x = 1;
>   y = 2;             
> endfunction
>
> b=test(2)                // eval 1
> b=evstr('test(2)')       // eval 2
> b=eval('test(2)')        // eval 3
>
> [x,y]=test2(2)           // eval 4
> [x,y]=evstr('test2(2)')  // eval 5
> [x,y]=eval('test2(2)')   // eval 6
>
>
eval returns the value of the evaluation of a matrix of strings.
If there is one string, eval returns 1 value, if there is 2 strings, 
eval returns 2 values.
If you want to get several parameters of a function, use execstr:

execstr('[x,y] = test2(2)');

YC



More information about the users mailing list