How to solve stiff ODEs with MATLAB Coder?

1 回表示 (過去 30 日間)
Katharina Henn
Katharina Henn 2020 年 12 月 17 日
コメント済み: Ameer Hamza 2020 年 12 月 17 日
I want to solve a stiff ODE, which works fine with the built in ode15s solver. To perform my task faster, I like to use MATLAB Coder to formulate the problem in C++. Due to lack of support for ode15s, I have used ode45 to solve my ODE. But this solver does not find the ODE's solution.
The solvers for stiff ODEs (ode15s and ode23s) are both not supported by the MATLAB Coder.
Therefore: Is there a way to solve stiff ODEs in C++ by generating code with the MATLAB Coder?

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 17 日
No, unless MathWorks add support, there is no way to generate the C code for these functions. However, you can try this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/24927-first-order-stiff-ordinary-differential-equation-solver. It seems to be using the basic functions, so you should be able to generate the C code.
  2 件のコメント
Katharina Henn
Katharina Henn 2020 年 12 月 17 日
Thank you for your suggestion, but as far as I have seen the function is not able to solve a system of coupled differential equations like I want to solve it.
But of course it would be possible to write an own solver for my system of ODEs.
Ameer Hamza
Ameer Hamza 2020 年 12 月 17 日
Yes, other than writing your own solver, there is no other way in MATLAB to generate C code.
Btw, if your main concern is execution speed, then it might not be worth the effort. MATLAB JIT compiler also does a pretty good job of compiling the frequently called functions at runtime. You might not see a significant improvement,

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by