ASE 311 HW #11 part 2 - Usman Ansari ASE 311 HW #11 1.)...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Usman Ansari ASE 311 HW #11 1.) (massSpring 2) 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(4) plot(ti,yi(:,1), ti,yi(:,3), 'o' ) figure(2) plot(ti,yi(:,2), ti,yi(:,4), 'o' ) figure(3) plot(yi(:,1),yi(:,2)) [ti,yi] = generalODE(@massSpring2, [0 2*pi], [2;0;0;0], 100) 1 2 3 4 5 6 7-4-3-2-1 1 2 3 4 5 6 t x P os itions m as s 1 m as s 2 Usman Ansari ASE 311 HW #11 1 2 3 4 5 6 7-12-10-8-6-4-2 2 4 6 8 t v veloc ity m as s 1 m as s 2 Usman Ansari ASE 311 HW #11-2-1.5-1-0.5 0.5 1 1.5 2-4-3-2-1 1 2 3 4 x v phase plot Usman Ansari ASE 311 HW #11-2-1.5-1-0.5 0.5 1 1.5 2-4-3-2-1 1 2 3 4 5 6 pos ition m as s 1 position mass2 phas e plot (x m as s 1 vs . x m as s 2) Usman Ansari ASE 311 HW #11 2.) 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);k3 = dydt(ti(i) + 0....
View Full Document

Page1 / 14

ASE 311 HW #11 part 2 - Usman Ansari ASE 311 HW #11 1.)...

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

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