# Solve system of differential equations

4 views (last 30 days)
Yokuna on 16 May 2022
Commented: Torsten on 16 May 2022
I am facing problem in solving the differential equation
is a vector () as shown in code and is also a vector (). x11=[x1,y1]. I want to solve , where represents derivative with respect to time. Can any one help me to find out x11 vs time. (Note and x11 are the same.) (Preferably use fsolve as I tried using it).
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);
hess1 = hessian(L1,x11');
u1=-beta*(hess1)^(-1)*x11+phi1
u1 =
##### 2 CommentsShowHide 1 older comment
Yokuna on 16 May 2022
Thanks for pointing out, I have corrected the question.

Torsten on 16 May 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);
hess1 = hessian(L1,x11');
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 CommentsShowHide 1 older comment
Torsten on 16 May 2022
Replace
fun = @(t,y)fun(t,x1,y1);
by
fun = @(t,y)fun(t,y(1),y(2));

### Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by