Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

solving with ode23, error using feval?

Asked by Greta

Greta (view profile)

on 14 May 2013

I want to solve a group of differential equations using ode23, but it always gives me the same error, which is:

??? Error using ==> feval
Undefined function or method 'funsys' for input arguments of type 'double'.
Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.
Error in ==> ode23 at 172
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

I don't know exactly what is these referring to, so I wanted to ask why is it giving me these errors?? The code of the function is:

function pX=funsys(t,X)
Ie1=X(1);
Ie2=X(2);
Ir1=X(3);
Ir2=X(4);
wr=X(5);
theta=X(6);
Le=0.4112;
Lr=0.329;
M=0.4112;
w=377;
R=3;
Tm=0;
Ve1=sqrt(2)*150*sin(w*t);
Ve2=sqrt(2)*150*cos(w*t);
I=[Ie1;Ie2;Ir1;Ir2];
L=[1.1*Le 0 M*cos(theta) -M*sin(theta);0 1.1*Le -M*sin(theta) M*cos(theta);M*cos(theta) -M*sin(theta) 1.1*Lr 0;-M*sin(theta) M*cos(theta) 0 1.1*Lr];
dL=[0 0 -M*sin(theta) -M*cos(theta);0 0 -M*cos(theta) -M*sin(theta);-M*sin(theta) -M*cos(theta) 0 0;-M*cos(theta) -M*sin(theta) 0 0];
vR=R*eye(4);
vV=[Ve1;Ve2;0;0];
vImp=vR+wr*dL;
Linv=inv(L);
L1=Linv(1,:);
L2=Linv(2,:);
L3=Linv(3,:);
L4=Linv(4,:);
A=vV-vImp*I;
Te=(I'*dL*I)/2;
pIe1=L1*A;
pIe2=L2*A;
pIr1=L3*A;
pIr2=L4*A;
pwr=Te+Tm/J;
ptheta=wr;
pX=[pIe1;pIe2;pIr1;pIr2;pwr;ptheta];

Then in the command window:

y0=[0 0 0 0 0 0]
st=0:0.001:10
[t,X]=ode23(@funsys,st,y0)

Thank you very much.

1 Comment

David Sanchez

David Sanchez (view profile)

on 14 May 2013

Please, use the {}Code option to tell what's code from comment.

Greta

Greta (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 16 May 2013

Perhaps you did not save your code into the file funsys.m on your MATLAB path.

0 Comments

Walter Roberson

Walter Roberson (view profile)

Contact us