MATLAB: Getting “Not enough Input arguments” for this code. Can some one help

ode

function yp=qcar(t,z)
M=1000;
m=100;
Cs=1000;
Ks=36000;
Kt=360000;
R=150;
yp=zeros(4,1);
yp(1)=z(2);
yp(2)=-1/M*[Ks(z(1)-z(3))+Cs(z(2)-z(4))];
yp(3)=z(4);
yp(4)=-1/m*[Ks(z(1)-z(3))+Cs(z(2)-z(4))-Kt(z(3)-R)];
And in another .m file
z0=[0,0,0,0];
[t,z]=ode113(qcar,[0:0.2:10],f0);
plot(t,z);

Best Answer

You made multiple mistakes in the function: I have rectified them check it.
z0=[0,0,0,0];
[t,z]=ode113(@qcar,[0:0.2:10],z0);
plot(t,z);
function yp=qcar(t,z)
M=1000;
m=100;
Cs=1000;
Ks=36000;
Kt=360000;
R=150;
yp=zeros(4,1);
yp(1)=z(2);
yp(2)=-1/M*[Ks*(z(1)-z(3))+Cs*(z(2)-z(4))];
yp(3)=z(4);
yp(4)=-1/m*[Ks*(z(1)-z(3))+Cs*(z(2)-z(4))-Kt*(z(3)-R)];
end