Rick rodey 21020 hw 5 problem 1 this script calls a

This preview shows page 3 - 7 out of 15 pages.

%Rick Rodey , 2.10.20, HW 5, Problem 1%This script calls a function of coordinate equations and prints the time%and location a projectile hits the groundclear;clc;%call the functionfunc = @ProjectileLocation;%Set peramitorsip = 1.5;% used intial point to set up for fzero (point assuming possiblecannon height)%use fzero to find timet = fzero(func,ip);%zeros of y at t%define peramitors for x equationv = 13.5;%intial veloctyTheta = (89*pi)/180;%theta converted to radians
Week 5 HomeworkENGR 112Fzero whileg = 9.8;%gravity%equation to find to x value for the time at which it hit the groundx = v.*t.*cos(Theta);%print the time it hits ground and the x point it doesfprintf('The projectile hits the ground at time: %0.4f(s)\nThe location ithit at is: %0.4f(m)\n',t,x)Function Files% Copy and paste your functions here (if any were used). Must be size 10,same as MATLAB font and color.functiony = ProjectileLocation(t)%PROJECTILE LOCATION Summary of this function goes here%This function gets the t value and calcs the y%location based on equation%Detailed explanation goes here%defined set variablesg = 9.8;%constant gravity on earth m / s^2Theta = (89.*pi)./180;% given launch angle in degrees – converted toradiansv = 13.5;% intial v in m / s%y coordinates from cannon based on intial v and thetay = v.*t.*sin(Theta)-(.5.*g.*(t.^2));endCommand Window OutputCopy and paste the command window output here (same font, size 10).The projectile hits the ground at time: 2.7547(s)The location it hit at is: 0.6490(m)>>
Week 5 HomeworkENGR 112Fzero while
Week 5 HomeworkENGR 112Fzero whileProblem 2Find all of the intersections of two functions ofx:F1(x) = 100e-x- 1 andF2(x) =sin(πx)in thedomain2 ≤x≤ 10.a)Plot both functions on the same graph. Draw X’s where the functions intersect.b)Print the x values for all of the intersections found.Use afororwhileloop to automatically find all of the intersections in the given domain (asopposed to estimating them by hand). Before printing your answers,filter outall solutions thatare duplicates or are outside of the domain given in the question.The numerical approximation that you’re using in this problem (fzero) can cause headaches ifyou’re not careful, so be sure to read the hints below.Hint 1: How do you make an anonymous function that takes one variable (x) and returns zerowhen the two functions intersect?Hint 2: You need to call fzero a bunch of times with a reasonable set of guesses, enough to makesure that you actually get all of the intersections.Each time you calculate a new intersection, compare itto ALL of the intersections that you have already calculated. If the difference between the newintersection and any of the old ones is very small(<0.00006), do not add it to your list and just move onto calculating the next one. Don’t forget to check that the intersection is in the given domain.a)[+10 Extra credit] In hint #2, why should you use (currentRoot – oldRoots) <0.00006instead of (currentRoot – oldRoots)== 0? Write your answer in the Word document.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 15 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Squires,N.
Tags
fprintf, Rick Rodey

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture