Solving dependent functions using ODE45

1 次查看(过去 30 天)
Hi All,
I am trying to solve a set of equations that are dependent on each other. dx_dt(1) is dependent on dx_dt(2). dx_dt(2) and dx_dt(3) are dependent on dx_dt(1). I have not been able to solve this. Any suggestions are greatly appreciated.

采纳的回答

Star Strider
Star Strider 2016-6-24
The ode45 and other functions (choosing the appropriate solver is important) are able to solve such systems of differential equations relatively easily. Please post your code for your differential equation funciton, and original equations if necessary.
  5 个评论
Star Strider
Star Strider 2016-6-28
The use of global variables is a remnant of earlier computer languages (like FORTRAN II that I learned programming with back in 1968) when that was the only way to pass variables and avoid some restrictions on subroutine (MATLAB function) usage. They are vestigial, and will eventually disappear. They are definitely to be avoided in MATLAB code.
One other problem you mentioned in a subsequent Question was that ‘dxdt(1)’ requires ‘dxdt(2)’. I would eliminate the double subscripts (that could be part of the problem), and instead insert a line defining ‘dxdt’ as a column vector from the outset:
...
iLoad = vC/Rload;
dxdt = zeros(7,1);
dxdt(1) = (x*(Vs - vC) + y*(-vj1 - Lp1*dxdt(2) - vC))/L; % diL/dt
...
and so for the others. I’m not certain that will solve your problem, since I didn’t run your code, but it should at least eliminate the problem you mentioned.
Torsten
Torsten 2016-6-29
@Josh:
Take the first and the second equation (dxdt(1,:) = ... and
dxdt(2,:) = ...) and solve for dxdt(1) and dxdt(2) (2 linear equations in two unknowns).
Alternatively, use the mass-matrix option of the ODE integrators.
Best wishes
Torsten.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by