Declare 'eval' function in Embedded MATLAB

7 ビュー (過去 30 日間)
Tong-Seop
Tong-Seop 2011 年 3 月 4 日
I made a secant method for complicated equation in MATLAB edit space. Like this... Function y = fcn(st, cq, a, g, ...) f=''3600 * st * cq * a * ((((2 * g * gam * pi)..........'; (Flow Function eq)
Of course, there is simple secant method.
n=0; x = xa; fa = eval(f); x = xb; fb = eval(f); .......
and then I put this script in Embedded MATLAB of Simulink. For 'eval' function, I also put 'eml.extrinsic('eval') in it.
When I start the simulation, I could see an error *"Call to MATLAB function aborted : Error using ==> eval Undefined function or variable 'st'."*
Thanks for your help.

採用された回答

Walter Roberson
Walter Roberson 2011 年 3 月 4 日
And does "st" indeed exist in your matlab workspace at the time? When you construct a string like that, the current value of the variable is not recorded.
If it is allowed on embedded systems, you would be better of constructing f as an anonymous function
f = @(x,n) 3600 * st * cq etc
and then you would invoke
fa = f(x, n);
fb = f(x, n);
  1 件のコメント
Tong-Seop
Tong-Seop 2011 年 3 月 4 日
st, cq... are input data from simulink.
Thanks for your kindness.
But I'm not sure that the anonymous function (you made) is possible in embedded matalb.
But thanks, it helped.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by