Help solving a system of differential equations
Show older comments
I have the following system of differential equations, and I am not able to understand the best way to go about them. I tried using a couple of functions like dsolve, ode45, etc., but most of them give errors that I am not able to understand.
x(1)=0.3; x(3)=0.9; y(1)=0.4; y(3)=0.8;
A=10; p=10;
syms X1 X2;
num = ((x(3)-X1)-(X1-x(1)))*X1 + ((y(3)-X2)-(X2-y(1)))*X2;
den = sqrt((x(3)-X1)-(X1-x(1))^2 + (y(3)-X2)-(X2-y(1))^2);
Em = -A*(X1-x(1))*(x(3)-X1) - A*(X2-y(1))*(y(3)-X2) + p*num/den;
dXdt = [-diff(Em,X1); -diff(Em,X2)];
I would like to get X1 and X2 as a function of time. If I define syms X1(t) and X2(t), I get the error 'All arguments, except for the first one, must not be symbolic functions.' The above code, when run, gives me expressions in terms of X1 and X2. I need solutions of X1 and X2 in terms of t, where dX1dt = -diff(Em,X1), dX2dt = -diff(Em,X2).
Any help is appreciated. Thank you!
2 Comments
Stephan
on 15 May 2018
Hi,
is it correct, that x and y are depending on t --> so: x(t) and y(t)?
Best regards
Stephan
Tejas Adsul
on 15 May 2018
Edited: Tejas Adsul
on 15 May 2018
Accepted Answer
More Answers (1)
Hi,
did i understand right:
x1=0.3;
x3=0.9;
y1=0.4;
y3=0.8;
A=10;
p=10;
syms X1 X2;
num = ((x3-X1)-(X1-x1))*X1 + ((y3-X2)-(X2-y1))*X2;
den = sqrt((x3-X1)-(X1-x1)^2 + (y3-X2)-(X2-y1)^2);
Em = -A*(X1-x1)*(x3-X1) - A*(X2-y1)*(y3-X2) + p*num/den;
dEm_dX1 = diff(Em,X1)
dEm_dX2 = diff(Em,X2)
dX1dt = -dEm_dX1
dX2dt = -dEm_dX2
This is what you wanted to do?
gives:
dX1dt =
(40*X1 - 12)/(17/10 - X2 - (X2 - 2/5)^2 - (X1 - 3/10)^2 - X1)^(1/2) - 20*X1 + ((2*X1 + 2/5)*(10*X1*(2*X1 - 6/5) + 10*X2*(2*X2 - 6/5)))/(2*(17/10 - X2 - (X2 - 2/5)^2 - (X1 - 3/10)^2 - X1)^(3/2)) + 12
dX2dt =
(40*X2 - 12)/(17/10 - X2 - (X2 - 2/5)^2 - (X1 - 3/10)^2 - X1)^(1/2) - 20*X2 + ((2*X2 + 1/5)*(10*X1*(2*X1 - 6/5) + 10*X2*(2*X2 - 6/5)))/(2*(17/10 - X2 - (X2 - 2/5)^2 - (X1 - 3/10)^2 - X1)^(3/2)) + 12
Can this be correct?
Best regards
Stephan
1 Comment
Tejas Adsul
on 15 May 2018
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!