How structure code for an equation with multiple variables that change with time.
古いコメントを表示
Hello,
Im relativley new to MATLAB nan coding and unsure how to proceed in structuring my Matlab code.
For instance. if I had an equation (1) that out puts (a) and has mutliple varibles (B), (C), and (D) that all are made up of of an equation that varies with time (t) how should I structure my code. Should I be using Function, while or For loops?
a = b + c + d
and time (t) equals a constant (e) divided by (a)
t = a/e
This may be a bit of a vauge question but any examples of how I might structure this would be awesome. Any suggestions on the format would be great. Any General Solution would be great.
(t) can finish at any time (t_n) or if another variable hits a certain point
I am working through the free MATLAB training so I am able to understand how individual elements of code works but just unsure how to put it all together.
3 件のコメント
Walter Roberson
2025 年 2 月 13 日
編集済み: Walter Roberson
2025 年 2 月 13 日
We need more context. The answer is going to be different if you are using Partial Differential Equation Toolbox, compared to if you are using Ordinary Differential Equations, or compared to if you are doing some kind of optimization; and different again if you are using Simscape
Hi @MIchael
Begin by thoroughly understanding the mathematical concepts related to the system. For instance, if you know that some variables vary with time, you can describe these variables
as either a function of time,
, or as the rate of change,
, which represents the speed at which the variable
changes over a specific period. This allows you to integrate
to obtain
. The latter is known as an Ordinary Differential Equation (ODE).
If you need to repeatedly compute the state of a variable using the same function
that varies with time, you must determine whether to use a vectorized-time approach or a looping approach for a specific time interval.
MIchael
2025 年 2 月 13 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!