Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I really need help on this matlab code....plz Write matlab code for Euler\'s met

ID: 3694821 • Letter: I

Question

I really need help on this matlab code....plz

Write matlab code for Euler's method. Apply your code to solve x = 3x/4 over t epsilon [0,2] with initial condition x(0) = 5. Do this for n = 10, 10^2, 10^3, 10^4 and 10^5 steps. Also obtain the true solution analytically. Plot the true solution and your approximate solutions for the various n values all on the same graph. Compute the error at the final time for each of the approximations. On a separate graph, plot the log_10 of the error versus the log_10 of the step size. Discuss the slope of this plot.

Explanation / Answer

>> clear x;

>> clear t;

>> a=0;

>> b=2;

>> n=10;

>> x0=5;

>> h=(b-a)/n;

>> x(1)=a;

>> t(1)=x0;

>> for N=1:n

x(N+1)=x(N)+h;

t(N+1)=t(N)+h*f(x(N),t(N));

end

>> plot(x,t,'r');

>> hold on;

>>plot(x,x0);

I have created m files one for function ,one for exact solutions.

cant paste screenshots

do error part yourself