function question1 y=1; h=.02; t=0 tic for i=1:2500 hold on t(i+1)=t(i)+h; y(i+1)=y(i)+h*f(t(i),y(i)) plot(t,y,'r--') xlabel('t'); ylabel('y') title('Eulers Method for function question1') endfunction actual=g(t,y)actual=((5*ones*exp(-(2*t)))-(3*ones*exp(-(4*t))))/2;figure(2)hold allplot(t,y);function question1=f(t,y)question1=(3*ones*exp(-(4*t)))-2*y;function error=h(t,error)error=abs(actual-question1)/actual;figure(3)plot(t,error,':')xlabel('t') % Labels ??x?? axis
ylabel('Error') % Labels ??y?? axis
title('Error using Euler Method');
MATLAB: How to get all functions in this code on one figure? It is only displaying the plot from the first function.
eulerfunctions
Best Answer