I am getting error not enough input arguments.
function fval=massSpringFun(t,y)
%Function for mass-spring system
%Define constants
m=1;
c=0.001;
k=100;
h=0.01;
x1=0.01;
x2=0;
%This set of ODEs will be solved using ode45
x1=y(1);
v1=y(2);
x2=y(3);
v2=y(4);
%Definr dy/dt
fval(1,1)=v;
fval(2,1)=(k/m)*(x1-x2)-(c/h)*v2;
%To run the mass spring system
y0=[1;0];
tspan=[0 10];
[tsol,ysol]=ode45(@(t,y)massSpringFun(t,y),tspan,y0);
plot(tsol,ysol(:,1));function fval=massSpringFun(t,y)
%Function for mass-spring system
%Define constants
m=1;
c=0.001;
k=100;
h=0.01;
x1=0.01;
x2=0;
%This set of ODEs will be solved using ode45
x1=y(1);
v1=y(2);
x2=y(3);
v2=y(4);
%Definr dy/dt
fval(1,1)=v;
fval(2,1)=(k/m)*(x1-x2)-(c/h)*v2;
%To run the mass spring system
y0=[1;0];
tspan=[0 10];
[tsol,ysol]=ode45(@(t,y)massSpringFun(t,y),tspan,y0);
plot(tsol,ysol(:,1)); function fval=massSpringFun(t,y)
%Function for mass-spring system
%Define constants
m=1;
c=0.001;
k=100;
h=0.01;
x1=0.01;
x2=0;
%This set of ODEs will be solved using ode45
x1=y(1);
v1=y(2);
x2=y(3);
v2=y(4);
%Definr dy/dt
fval(1,1)=v;
fval(2,1)=(k/m)*(x1-x2)-(c/h)*v2;
%To run the mass spring system
y0=[1;0];
tspan=[0 10];
[tsol,ysol]=ode45(@(t,y)massSpringFun(t,y),tspan,y0);
plot(tsol,ysol(:,1)); ode45 MATLAB Answers — New Questions