ode45 symbolic variable in odefun
9 ビュー (過去 30 日間)
古いコメントを表示
Hi everybody, I would like to kindly ask for your help. My problem is following: I am trying to solve the system of ODEs, which is represented by the symbolic matrix.
1) I have this odefunction:
function [y] = myFun(~,u)
global input
M=input.M;
v=input.v;
dui = M*u+v;
end
where M is a mentioned symbolic matrix (system of ODEs), v is a vector.
2) Then I have the main script, which calls ODE solvers and plots the results.
function main()
[t,y] = ode45(@myFun, tspan, y0, options);
...
end
Unfortunately, I am receiving this error: "Inputs must be floats, namely single or double."
I know, that ode45 is not designed for symbolic expressions. Of course, I tried to google it, etc., but I still cannot find the right solution. For example, I tried:
f = matlabFunction(myFun(tspan,y0))
[t,y] = ode45(f, tspan, y0, options);
but I am getting another error message: "Error using symengine>@()[-3.048662226349097;-5.801428662968666;-7.984664189221292;.....] Too many input arguments." and "Error in odearguments f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0."
Please, do you have any experience with this kind of problem? Many thanks in advance.
0 件のコメント
回答 (2 件)
Star Strider
2017 年 6 月 16 日
Note that your anonymous function:
@()[-3.048662226349097;-5.801428662968666;-7.984664189221292;.....]
does not accept any input arguments, so any input argument values passed to it will throw that error.
0 件のコメント
Steven Lord
2017 年 6 月 16 日
Use the ODE solvers in MATLAB, like ode45, to numerically solve ODEs represented as a function handle that ode45 can evaluate to return a numeric answer.
Use the ODE solver function dsolve in Symbolic Math Toolbox to solve an ODE symbolically.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!