Differential Equations Solutions 115

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

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

View Full Document Right Arrow Icon
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]);
Background image of page 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

This note was uploaded on 01/21/2012 for the course MAP 3302 taught by Professor Dr.robin during the Fall '11 term at University of Florida.

Ask a homework question - tutors are online