Solve system of differential equations
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am facing problem in solving the differential equation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999685/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999690/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999695/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999690/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999705/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999710/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999685/image.png)
close all
clear all
clc
x01=-5;y01=-7;
x0=[x01,y01]';
beta=25;
syms x1 y1 t
x11=[x1,y1]';
c1=(1/2)*(x1-i*sin(t))^2+(3/2)*(y1-i*cos(t))^2;
row=100*exp(0.1*t);
g1=y1-x1-cos(t);
L1=c1-(1/row)*log(1-row*g1);
grad1 = gradient(L1,x11');
hess1 = hessian(L1,x11');
phi1=-(hess1)^(-1)*(grad1+diff(grad1,t));
u1=-beta*(hess1)^(-1)*x11+phi1
2 commentaires
Torsten
le 16 Mai 2022
u1 is a 2x2 matrix, x11 is a 2x1 vector.
What do you mean by
x11dot = u1
?
Maybe you mean
x11dot = u1*x1
?
Réponse acceptée
Torsten
le 16 Mai 2022
x01=-5;y01=-7;
x0=[x01,y01]';
beta=25;
syms x1 y1 t
x11=[x1,y1]';
c1=(1/2)*(x1-i*sin(t))^2+(3/2)*(y1-i*cos(t))^2;
row=100*exp(0.1*t);
g1=y1-x1-cos(t);
L1=c1-(1/row)*log(1-row*g1);
grad1 = gradient(L1,x11');
hess1 = hessian(L1,x11');
phi1=-(hess1)^(-1)*(grad1+diff(grad1,t));
u1=-beta*(hess1)^(-1)*x11+phi1
fun = matlabFunction(u1,'Vars',{t,x1,y1})
fun = @(t,y)fun(t,x1,y1);
y0 = [x01,y01];
tspan = [0 1]
[T,Y] = ode45(fun,tspan,y0)
plot(T,[real(Y),imag(Y)])
2 commentaires
Torsten
le 16 Mai 2022
Replace
fun = @(t,y)fun(t,x1,y1);
by
fun = @(t,y)fun(t,y(1),y(2));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!