Mathematics - The MathWorks - #201

/ 316


catalogue search
P. 201
P. 202
P. 203
P. 204
P. 205
P. 206
P. 207
P. 208
P. 209
P. 210
P. 211
P. 212
P. 213
P. 214
P. 215
P. 216
P. 217
P. 218
P. 219
P. 220
P. 221
P. 222
P. 223
P. 224
P. 225
P. 226
P. 227
P. 228
P. 229
P. 230
P. 231
P. 232
P. 233
P. 234
P. 235
P. 236
P. 237
P. 238
P. 239
P. 240
P. 241
P. 242
P. 243
P. 244
P. 245
P. 246
P. 247
P. 248
P. 249
P. 250


See other catalogues for The MathWorks

Text version of the page
ODEs
teout = []; yeout = []; ieout = []; for i = 1:10
% Solve until the first terminal event.
[t,y,te,ye,ie] = ode23(@f,[tstart tfinal],y0,options);
if ~ishold hold on
end
% Accumulate output, nt = length(t); tout = [tout; t(2:nt)]; yout = [yout; y(2:nt,:)];
teout = [teout; te]; % Events at tstart are never reported. yeout = [yeout; ye]; ieout = [ieout; ie];
ud = get(gcf,'UserData'); if ud.stop
break; end
% Set the new initial conditions, with .9 attenuation.
y0(1) = 0;
y0(2) = -.9*y(nt,2);
% A good guess of a valid first time step is the length of % the last valid time step, so use it for faster computation, options = odeset(options,'InitialStep',t(nt)-t(nt-refine),...
'MaxStep',t(nt)-t(1)) ;
tstart = t(nt); end
plot(teout,yeout(:,1),'ro') xlabel('time'); ylabel('height');
title('Ball trajectory and the events');
hold off
odeplot([],[],'done');
6-27

pageCatalog pdf di En 2012-06-22-01