![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/180660/image.png)
How to solve and write system of differential equations?
4 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Abraham Boayue
2018-3-29
编辑:Abraham Boayue
2018-3-29
R1 = 500; R2 = 800; R3 = 1000; R4 = 200; C1 = 0.1;
C2 = 0.1; V = 180;
F = @(t,y)[y(1);
(y(1)/R1 -(y(2)-y(3)-V/R4-R1*y(2))/(R1*C1));
((y(2)-y(3)-V/R4-R1*y(2))/(R2*C1)-(y(3)-V/R3-R1*y(2)-R2*y(3))/(R2*C2))];
tspan = [1 2];
yin = [0 0 0];
[t,y]=ode45(F,tspan,yin);
plot(t,y(:,2),'linewidth',1.5,'color','b')
hold on
plot(t,y(:,3),'linewidth',1.5,'color','r')
grid;
a = title('I_1 and I_2');
legend('I_1','I_2');
set(a,'fontsize',14);
a = ylabel('y');
set(a,'Fontsize',14);
a = xlabel('t [0 1]');
set(a,'Fontsize',14);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/180660/image.png)
3 个评论
Abraham Boayue
2018-3-30
编辑:Abraham Boayue
2018-3-30
You are welcome, you have two systems of ODE with three unknown quantities (I1, I2 and v ). It is not possible to solve for three variables given two equations. I made up the third equation to be able to get a solution. Your new function above is invalid because you haven't got that many ode in your problem. You actually have two 1st order equations which can not be further reduced. Check and see if you can obtain a third equaton involving dv/dt from the circuit diagram that you are working with. My solution is based on an assumption that dv/dt is as defined in the paper attached and may not be correct with respect to your problem. See this link on a similar problem : https://www.mathworks.com/matlabcentral/answers/391390-how-to-solve-nonlinear-coupled-dgl-second-order
更多回答(2 个)
Abraham Boayue
2018-3-28
编辑:Abraham Boayue
2018-3-28
Ì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)
Abraham Boayue
2018-3-28
编辑:Abraham Boayue
2018-3-28
Because the differential equation in line 1 is coupled, we will have to find a way to separate dv/dt from dI/dt.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!