ASE 311 HW #11 part 1 - plot(ti,yi(:,1)) figure(2)...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Usman Ansari ASE 311 HW #11 ASE 311 HW#11 1.) (massSpring 1) function [ti,yi] = generalODE(dydt, tspan, y0, nSteps) z = length(tspan); ti = linspace(tspan(1), tspan(z), nSteps+1); h=(tspan(z)-tspan(1))/nSteps; yi(1,:)=y0; for i=1:nSteps k1 = dydt(ti(i),yi(i,:)); k2 = dydt(ti(i) + 0.5*h, yi(i,:)' + 0.5*h*k1); k3 = dydt(ti(i) + 0.5*h, yi(i,:)' + 0.5*h*k2); k4 = dydt(ti(i) + h, yi(i,:)' + h*k3); yi(i+1,:) = yi(i,:) + h/6*(k1+2*k2+2*k3+k4)'; end figure(1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: plot(ti,yi(:,1)) figure(2) plot(ti,yi(:,2)) figure(3) plot(yi(:,1),yi(:,2)) figure(4) plot(yi(:,1), yi(:,3)) [ti,yi] = generalODE(@massSpring1, [0 2*pi], [2;0], 100) 1 2 3 4 5 6 7-2-1.5-1-0.5 0.5 1 1.5 2 t x(position) position Usman Ansari ASE 311 HW #11-2-1.5-1-0.5 0.5 1 1.5 2-2-1.5-1-0.5 0.5 1 1.5 2 x v phase plot (x vs v) 1 2 3 4 5 6 7-2-1.5-1-0.5 0.5 1 1.5 2 t velocity Usman Ansari ASE 311 HW #11...
View Full Document

This note was uploaded on 02/13/2010 for the course ASE 311 taught by Professor Kraczek during the Spring '08 term at University of Texas at Austin.

Page1 / 3

ASE 311 HW #11 part 1 - plot(ti,yi(:,1)) figure(2)...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online