{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ASE 311 HW #11 part 1

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

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

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)

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

View Full Document
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

{[ snackBarMessage ]}

### Page1 / 3

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

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

View Full Document
Ask a homework question - tutors are online