Write Matlab function given an ODE and initial conditions

2 ビュー (過去 30 日間)
Sara Westerlund
Sara Westerlund 2022 年 3 月 2 日
編集済み: Torsten 2022 年 3 月 2 日
From this ODE
How do I write a Matlab program that calculates p at time 1.5 time units given a value of k3. I want to do a Matlab function that takes k3 as input and outputs p (1.5)?
Given the following s0 = 2.2, e0 = 2.8, k1 = 11 och k2 = 1.6.
With start values ​​s (0) = s0, e (0) = e0, c (0) = c0 = 0 and p (0) = p0 = 0
  3 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 3 月 2 日
Why not? They are developed by experts in the field, that have gone to some considerable lengths to provide a suite of different solvers for ODEs with most types of numerical characteristics. If you know the shortcomings of these solvers for your type of ODE then you should also have sufficient competence to "roll your own" solver, but that doesn't fit very well with your "have used Euler's method before".
Torsten
Torsten 2022 年 3 月 2 日
編集済み: Torsten 2022 年 3 月 2 日
Most probably, it's an assignment for which the OP has to program Euler's method.

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

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 3 月 2 日
Have a look at the ODE-examples, both the demos and the corresponding code:
>> odeexamples
That should give you a good starting introduction to how you should go about implementing your ODEs. Then you can also look at the help and documentation to ode45 and its siblings.
HTH

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by