15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Initial Value Problems for ODEs and DAEs<br />

tstart = t(nt);<br />

end<br />

plot(teout,yeout(:,1),'ro')<br />

xlabel('time');<br />

ylabel('height');<br />

title('Ball trajectory and the events');<br />

hold <strong>of</strong>f<br />

odeplot([],[],'done');<br />

% --------------------------------------------------------------<br />

function dydt = f(t,y)<br />

dydt = [y(2); -9.8];<br />

% --------------------------------------------------------------<br />

function [value,isterminal,direction] = events(t,y)<br />

% Locate the time when height passes through zero in a<br />

% decreasing direction and stop integration.<br />

value = y(1); % Detect height = 0<br />

isterminal = 1; % Stop the integration<br />

direction = -1; % Negative direction only<br />

25<br />

Ball trajectory and the events<br />

20<br />

15<br />

height<br />

10<br />

5<br />

0<br />

0 5 10 15 20 25 30<br />

time<br />

5-31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!