Reputation: 1
We have some MatLab code that includes lines such as:
fTE2D = @(x) (0.0049.*WP^2 + 2.4417.*WP).*((y^(2)+x^(2))^(1/2))^(-0.128.*log(WP) - 1.7855)-SecondD;
Which we would like to translate to SciLab. Cannot find reference to function handle (Matlab @)
in SciLab.
Upvotes: 0
Views: 938
Reputation: 412
This Matlab instruction creates an "anonymous" functionand stores it in the fTE2D
variable
In Scilab all functions are variables you can create a similar function with
function y=fTE2D(x)
y= (0.0049.*WP^2 + 2.4417.*WP).*((y^(2)+x^(2))^(1/2))^(-0.128.*log(WP) - 1.7855)-SecondD; ;
endfunction
A significative difference however
In Matlab WP
, y
and SeconD
has to be defined before the anonymous function
is created and their values are stored in the fTE2D
variable.
With Scilab the WP
, y
and SeconD
value are taken from the calling scope
when the function is called.
example
With Matlab
>> a=2
>> foo=@() sqrt(a)
>> foo()
ans =
1.4142
>> a=4
>> foo()
ans =
1.4142
with Scilab
--> function y=foo(),y=sqrt(a);endfunction
--> a=2;
--> foo()
ans =
1.4142
--> a=4;
--> foo()
ans =
2
Upvotes: 1