How to fix Odearguments errors ode45 function

A = [0 1;-20 -10];
B = [0;10];
p=[-40;-50]
C2 = poly(A);
w=[C1(2) 1;1 0];
T=C*w;
C3 = poly(p);
K=[C3(3)-C2(3) C3(2)-C2(2)]*inv(T);
X0= [0.3;0];
Xref = [3;0];
%solver
Tspan=[0 5];
[t,x] = ode45(@spring, Tspan, X0);
function Y = spring(t,x)
global K Xref A B
X = [x(1);x(2)];
u = K*(Xref-X);
Y= A*X+B*u;
I am getting the following error, can some please help
Error using -
Arrays have incompatible sizes for this operation.
Error in spring (line 4)
u = K*(Xref-X);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in First_second (line 44)
[t,x] = ode45(@spring, T, X0);

Réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by