Filter löschen
Filter löschen

Compile ODE solver with parameterized function

2 Ansichten (letzte 30 Tage)
Jannis TW
Jannis TW am 23 Nov. 2018
Beantwortet: Ryan Livingston am 27 Nov. 2018
How can I compile a call to a ODE with a parameterized function? Lets take the example from ode45:
function y = odeTEST()
A = 1;
B = 2;
tspan = [0 5];
y0 = [0 0.01];
[t,y] = ode45(@(t,y) odefcn(t,y,A,B), tspan, y0);
end
function dydt = odefcn(t,y,A,B)
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = (A/B)*t.*y(1);
end
save them as .m files and and compile it with
codegen -config:dll odeTEST
it will give me
??? Anonymous functions are not supported for code generation
(This is related, but not identical to my other question on generating DLLs)

Akzeptierte Antwort

Ryan Livingston
Ryan Livingston am 27 Nov. 2018
As of MATLAB R2016b, code generation with MATLAB Coder supports anonymous functions:
In prior releases, you can mimic them using persistent variables as shown here:

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by