10_30 - 10.30 (continued) b). See attached codes and...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
10.30 (continued) b). See attached codes and results %problem 10.30(a) function solution1030a %solution to 10.30 %September 23,2008 b=1; m=1; g=10; % give values for b,m and g here %Initial conditions and time span tspan=[0:0.001:5]; %integrate for 50 seconds x0=0; y0=0; %initial position v0=50; %magnitude of initial velocity (m/s) theta0=20; %angle of initial velocity (in degrees) z0=[x0,y0,v0*cos(theta0*pi/180),v0*sin(theta0*pi/180)]'; %solves the ODEs [t,z] = ode45(@rhs,tspan,z0,[],b,m,g); %Unpack the variables x= z(:,1); y =z(:,2); v_x = z(:,3); v_y=z(:,4); %plot the results plot(x,y); xlabel( 'x(m)' ); ylabel( 'y(m)' ); %set grid,xmin,xmax,ymin,ymax axis([0,5,0,5]); title([ 'Plot of Trajectory for theta= ' ,num2str(theta0), ' degrees' ]); end %-----------------------------------------------------------------------% function zdot = rhs(t,z ,b ,m ,g) %function to define ODE x=z(1); y=z(2); v_x=z(3); v_y=z(4);
Background image of page 2
v_ydot=-g-(b/m)*v_y*(v_x^2+v_y^2)^0.5;
Background image of page 3

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

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

This document was uploaded on 05/07/2009.

Page1 / 6

10_30 - 10.30 (continued) b). See attached codes and...

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

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