Please Solve error occurring while solving differential equation with ode15s

function sync
a=4,b=1,c=1,k=12,d=4.5,f=21.9,z=1,beta=0;
E=[eye(4),zeros(4,2)];
A=[-a a 0 0 0 0;0 0 0 1 0 1;0 0 0 0 1 0;0 -c 0 0 0 0];
C=[1 1 2 0 0 0;3 2 1 2 3 3;2 0 0 1 1 0;2 3 2 2 3 3;1 2 0 0 0 0];
H = [eye(3),zeros(3)]
r1=rank(C)
[m,n] = size(E)%(m \leq n)
n=rank([E;C])
[U,D,V]= svd(C)
D1=D(1:5,1:5)
Q = (V.')*([inv(D1) zeros(5,1);zeros(1,5) eye(n-r1)])
E2 = E*Q*[zeros(r1,(n-r1));eye(n-r1)]
[u,D2,v]=svd(E2)
D22 =0.7518
Ro = [zeros(m+r1-n,1),eye(m+r1-n);v*D22,zeros(1,m+r1-n)]*u
R = Q*[zeros(n-m,m);Ro]
E_cap = R*E
e_cap =[E_cap, zeros(6);zeros(6) ,eye(6)]
A_cap = R*A
%calculating LMI
setlmis([])
P = lmivar(1,[size(A_cap,1) 1]);
K_cap = lmivar(2,[6 5]);
lmiterm([1 1 1 P],1,A_cap,'s');
lmiterm([1 1 1 K_cap],-1,C,'s');
lmiterm([1 1 1 0],z*f^2*H'*H);
lmiterm([1 1 1 0],beta*eye(6));
lmiterm([1 1 2 P],1,R);
lmiterm([1 2 2 0],-z*eye(4));
LMISYS = getlmis;
[tmin,Psol]=feasp(LMISYS);
[tmin,Ksol]=feasp(LMISYS);
P = dec2mat(LMISYS,Psol,P)
K_cap = dec2mat(LMISYS,Ksol,K_cap)
K = inv(P)*K_cap
N = A_cap-K*C
M = eye(6)*pinv(C)-E_cap*pinv(C)
L =K+N*M
tspan = 0:0.1:60;
x0 = [1;1;1;1;1;4.5;-1;-1;-1;-1;-1;-1];
opt = odeset('Mass',e_cap,'RelTol',1e-8,'AbsTol',1e-8);
[t,x] = ode15s(@odesync,tspan,x0,opt);
function dxdt = odesync(t,x)
F= [0;k*x(1)*sin(x(3));-x(1)*x(2);0]
F_cap= [0;k*x(7)*sin(x(9));-x(7)*x(8);0]
y = C*[x(1);x(2);x(3);x(4);x(5);x(6)]
x_cap = [x(7);x(8);x(9);x(10);x(11);x(12)]+M*y
dxdt = A_cap*[x(1);x(2);x(3);x(4);x(5);x(6)] + R*F;
N*[x(7);x(8);x(9);x(10);x(11);x(12)]+L*y + R*F_cap
end
end
My errors are:-
Error using odearguments (line 95)
SYNC/ODESYNC returns a vector of length 6, but the length of initial conditions vector
is 12. The vector returned by SYNC/ODESYNC and the initial conditions vector must have
the same number of elements.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in sync (line 43)
[t,x] = ode15s(@odesync,tspan,x0,opt);

 Risposta accettata

Just rewrite
dxdt = A_cap*[x(1);x(2);x(3);x(4);x(5);x(6)] + R*F;
N*[x(7);x(8);x(9);x(10);x(11);x(12)]+L*y + R*F_cap
to
dxdt =[ A_cap*[x(1);x(2);x(3);x(4);x(5);x(6)] + R*F;...
N*[x(7);x(8);x(9);x(10);x(11);x(12)]+L*y + R*F_cap];
Then it works, but you should still check some other errors

3 Commenti

Warning: Failure at t=2.292185e-04. Unable to meet integration tolerances without
reducing the step size below the smallest value allowed (4.336809e-19) at time t.
> In ode15s (line 668)
In sync (line 43)
>>program got run but getting this error now. Please tell me what is the meaning of this error?
@Meenakshi Tripathi That means the ode15s can't reach a converged solution, you may check your odefun or set the options to see how each integration step works

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by