E7_lecture7_F08_Function_handles_BW

# E7_lecture7_F08_Function_handles_BW - 1 E7 INTRODUCTION TO...

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

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

View Full Document
5 Function cannon1 function [t, x,y] = cannon1(v0,theta,g) [, ,y ] ( , ,g) % cannon computes the trajectory of a projectile fired at an angle theta % with initial velocity v0 under gravitational acceleration g % Outputs: t: time vector, x: - x-coordinate vector, y: y-coordinate vector % Compute flying time of the projectile tmax = 2*v0*sin(theta)/g; % Define time vector of length 100 t = linspace(0,tmax,100); % Compute x-coordinate vector x = v0*cos(theta) .* t; % Compute y-coordinate vector y = v0*sin(theta) .* t - 0.5*g .* t .* t; E7 L7 6 Function cannon1 nction x y] = cannon1(v0 theta g) function [t, x, y] = cannon1(v0,theta,g) 2 *0 *i( tht) / input scalar arguments tmax = 2*v0*sin(theta)/g; 3 input scalar arguments t = linspace(0,tmax,100); 3 vector output arguments x = v0*cos(theta) .* t; y = v0*sin(theta) .* t - 0.5*g .* t .* t;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern