f=@(x,y) cos(x); % Calculate exact solution g=@(x) cos(x); xe=(0:.1:100); ye=g(xe); % Call function [x4,y4]=ode45(f,[0,100],.1); % Plot plot(xe,ye,'k-',x4,y4,'o') xlabel('x') ylabel('y') legend('Analytical','ode45') axis([0 10 100 100])