{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Differential Equations Solutions 115

# Differential Equations Solutions 115 - [t,y =...

This preview shows page 1. Sign up to view the full content.

125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function yp = yprime(t,y) yp = [y(2); y(1)^2 - 5 * y(2)]; % End of yprime %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function f = fvalue(z) [t,y] = ode45(@yprime,[0 1],[5,z]); f = y(end,1)-2; % End of fvalue %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHALLENGE 20.17. function [t,y,z] = solvebvp() z = fzero(@evalshoot,[-1,1]);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [t,y] = ode45(@yprime,[0,1],[1,z]); % The true solution is . .. utrue = cos(pi*t/2) + t.^2; plot(t,y(:,1),t,utrue) legend(’Computed solution’,’True solution’) xlabel(’t’) ylabel(’u’) % end of solvebvp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function f = evalshoot(z) % Given a value for y(2) at time t=0, see how close...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online