How to solve and write system of differential equations?
Show older comments
Hi, I am trying to solve this system through ODE45, and I tried two ways:
First:
function dxdt = rlcf(t,x)
I4 = (V - R1 * x(1)) / R4;
I3 = (V - R1 * x(1) - R2 * x(2)) / R3;
I5 = x(1) - x(2) - I4;
I6 = x(2) - I3;
dxdt(1,1) = (1/R1)*((V)-(I5/C1));
dxdt(2,1) = (1/R2)*((I5/C1)-(I6/C2));
I don't now how i write dVdt in this case... and my code enter in continuous loop.
Second:
function dxdt = rlcf(t,x)
dxdt(1,1) = (1/R1)*((V)-((x(1) - x(2) - ((V - R1 * x(1)) / R4))/C1));
dxdt(2,1) = (1/R2)*(((x(1) - x(2) - ((V - R1 * x(1)) / R4))/C1)-(((V - R1 * x(1) - R2 * x(2)) / R3)/C2));
In this case, the results in vector are 'NaN'.
How I write dVdt in this case?
Accepted Answer
More Answers (2)
Abraham Boayue
on 28 Mar 2018
Edited: Abraham Boayue
on 28 Mar 2018
ÌCheck your function dxdt, it has two inputs but uses othe variables that aren't defined. Some of these are V, R1, R2. t is an input but never used. Your use of I1 to I6 is quite good. Here is my recommendation
function [dx1 dx2] = rlcf(x1,x2, R1, R2, R3, R4, V)
1 Comment
pml_28
on 28 Mar 2018
Abraham Boayue
on 28 Mar 2018
Edited: Abraham Boayue
on 28 Mar 2018
0 votes
Because the differential equation in line 1 is coupled, we will have to find a way to separate dv/dt from dI/dt.
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!