MATLAB: Not enough input arguments. in ode45

inputode45

Hi,
I am trying to run the code given as an example on mathworks website (https://www.mathworks.com/help/matlab/ref/ode45.html) for ode45 and still it is giving me the error saying : "Not enough input arguments"
This is the code:
function dydt = vdp1(m,y)
dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
[m,y] = ode45(@vdp1,[0 20],[2; 0]);
plot(m,y(:,1),'-o',m,y(:,2),'-o')
title('Solution of van der Pol Equation (\mu = 1) with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
I am trying this as I am developing a new code based on this template and that is not working either.
What can I do?

Best Answer

[m,y] = ode45(@vdp1,[0 20],[2; 0]);
plot(m,y(:,1),'-o',m,y(:,2),'-o')
title('Solution of van der Pol Equation (\mu = 1) with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
% try the above in command window or in a separate script file
% ------------
function dydt = vdp1(m,y) % save this in a separate file named as vdp1.m
dydt = ...;