Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Content: for loops, rand random number function, if conditional statement, abs function, binary operators, function handles, min function, linspace Mathematical/Numerical Content: bisection algorithm, secant

image text in transcribedimage text in transcribedimage text in transcribed

MATLAB Content: for loops, rand random number function, if conditional statement, abs function, binary operators, function handles, min function, linspace Mathematical/Numerical Content: bisection algorithm, secant method, Newton's method Avalanche Control In order to prevent Avalanche disasters, cannons have been fired into the mountains to create controlled avalanches. The scenario for this lab is simple. You have a cannon that fires a projectile at a speed of 1000 m/s per second. We are going to ignore wind resistance jus (but we could add it in later if we wished) and predict the firing angle to hit a target some horizontal distance target away and at a vertical height Ytarget above where the cannon is. Simple Projectile Motion We need very little math for this problem. First, the vertical height of the projectile at a given moment in time, y(t), will be given (approximately) by s(t) = - t, where = 1000 sin(0) and the horizontal position is given by r(t) = vet, where w, = 1000 cos(0). We will need to determine the correct angle, 0, to hit our target. We have hit the target if for some time i, r(O) = 5000 and y(i)=500. Part A In order to solve this problem, our first step will be to code a function that takes as an input an angle, 0, as well as the value of Ttarget and returns the value of y(t) at the time t where r(t) = Ttarget. With a little mathematics, this is not to hard to determine. First figure out the time at which r(t) = Itarget, then use that time to evaluate y(t) and return that value. Use the above equations to first find t and then y. That is you will have a function L2PartA which inputs 0 and target and output a value for the height of the cannon ball after it has traveled the horizontal distance to the target. In order for you to be able to test your code, if Dearget= 5000 and 0 =*/8 radians, then the function should return a value of 1.927403688037477e+03. Please note, your code must use radians and not degrees! I MATLAB's Grader Submit your code in Part A. Part B When doing part B, in your code entered into MATLAB's Grader, you may freely use a function called L2PartA that is as described in Part A and works correctly. You can do this, even if you have not finished Part A (though it will only work in ZyBooks). You do not need to reenter a function called L2PartA. For Part B, you will be given a target (Ttarget, Ytarget) and you need to determine the correct angle you need in order to hit the target with the cannon. First we will use a Monte Carlo method. Write a function that has two inputs for target and ytarget. Inside the function, set a value for N. The randomly select a fixed number (N) of angles from /100 to 1/3. Then calculate the angle from your random list that produces the minimum difference between the y value returned by L2PartA and ytarget. Have the function return this angle and the difference between Ytarget and the actual value calculated for that angle. Run this code several time with target = 5000 and ytarget = 1000 and be sure that it produces a result accurate to the nearest meter each time. If it does not even once), increase N and try again. Part C When doing part C, you may again freely use a function called L2PartA. For Part C, you will be again be given a target (target, Ytarget) and you need to determine the correct angle 0 you need in order to hit the target with the cannon. Write a function that has two inputs for target and ytarget. Inside the function, set a value for N. The generate N equidistant angles from /100 to w/3. Then calculate the angle from your list that produces the minimum difference between the y value returned by L2PartA and Ytarget- Have the function return this angle and the difference between target and the actual value calculated for that angle. Run this code several time with different values for target (2500 target 7500) and ytarget (500 Ytarget

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions