Problem 2 Find the solution to the following initial value p
Problem 2 Find the solution to the following initial value problems once by using Euler\'s method and another time by using the Matlab ode45 function. In each case, after solving the problem, plot the solution obtained from the two different methods in the same figure similar to Figure (a) dy zsin(y) (a) 0 (0) 0.5 E 0,51 Page 2 of 3 Problem 2 coutinued on next page... 0.01 (b) y (0) 0.2 :(0) 0.1 0.01 (c) 1dy sin(y) 0 2 dr y(0) 1 ar E 0,20 0.05
Solution
n = size(V,1); k = size(V,2); U = zeros(n,k); U(:,1) = V(:,1)/sqrt(V(:,1)\'*V(:,1)); for i = 2:k U(:,i) = V(:,i); for j = 1:i-1 U(:,i) = U(:,i) - ( U(:,i)\'*U(:,j) )*U(:,j); end U(:,i) = U(:,i)/sqrt(U(:,i)\'*U(:,i)); end