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!