Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE MATLAB Background: Iterative Solution to Mechanics Problems In introductory physics, most problems can be solved algebraically, partly because simplifying assumptions are used (no air

USE MATLAB

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Background: Iterative Solution to Mechanics Problems In introductory physics, most problems can be solved algebraically, partly because simplifying assumptions are used (no air resistance, small-angle approximation, etc.). When more detailed and realistic descriptions of the physics are incorporated into a problem, it may not be solvable in closed form. In cases like this, numerical solutions are sought. One technique for solving problems numerically is iteration. An iterative solution proceeds as follows: make an initial assumption, or guess, about the solution apply this assumption to generate a first, approximate solution adopt the approximate solution as the new guess, and use it to calculate a second approximation continue this process, generating better and better approximations, until the solution converges - that is, until the next iteration does not change the solution significantly . Depending on the complexity of the problem, iterative solutions may or may not produce an accurate solution efficiently, independent of the initial guess. The problems that we are tackling in this assignment are amenable to an iterative approach- if your code is correct, you will get a good solution in a small number of iterations, regardless of your initial guess. Example: Accounting for the finite speed of sound Consider this problem A man drops a rock into a well. He hears the sound of the splash 2.40 s after he releases the rock from rest. How far below the top of the well is the surface of the water? The reason that this problem is not as trivial as it seems is that 2.40 s is not the time that it takes for the rock to hit the water, but rather the time that it takes for the echo to reach the top of the well. That is, it is the sum of the time for the rock to hit the water (t1) and the time for the echo to travel to the top of the well (t2). Although this problem can in fact be solved exactly, it is nonetheless a good example to illustrate the iterative method First approximation The starting assumption is that the time for the echo to travel to the top of the well is small compared to the time for the rock to hit the water. The first approximation for the depth of the well can therefore be calculated from simple kinematics as follows: Serwayand Jewett, Physics for Scientists and Engineers, 8th ed., problem 2.67 where g 9.81 m/s2 is the acceleration due to gravity at the surface of the earth. Since the rock is dropped, not thrown, o 0, and H-Aya gt-(9.81 m/s2) (2.40s)2 28.25 m Second approximation Given this initial estimate for the depth of the well, the time for the echo to propagate to the top, assuming speed of sound 340 m/s, is t2- (28.25 m)/340 m/s)- 0.083 This implies that the time for the rock to reach the water was not the full 2.40 s, but rather t1-2.40 s0.083s-2.317 s Therefore, a better estimate of the depth of the well is Hgt (9.81 m/s2) (2.317s)-26.33 m Of course, the process does not stop here. Based on this improved estimate for H, we can get a better estimate for t2, which leads to an even better estimate for H, and so on. Eventually, assuming that the calculation converges, the difference between subsequent estimates of H will be negligibly small. In this example, H converges within 5 iterations to a final value of 26.45 m. A logical diagram (flow chart) of this algorithm is shown below. This algorithm can be implemented using a while loop. The loop terminates when two subsequent approximations for the result (H and Hi) differ by less than a specified tolerance (TOL) Application 6: Iteration Designed to test skills with: looping, user-defined functions, iteration For this assignment, submit ALL of the following: function file (.m), script file (.m), and text ENGR 1221 output file (.txt) %Set parameter values Vs 340 m/s t 2.40 s %Initialize guesses 2-0, H10 %Calculate t1 %Calculate H H-H TOL? The Project: You are asked to use an iterative method to solve the following problem: You are manning an anti-aircraft gun with a muzzle velocity, V: An enemy aircraft is approaching on a horizontal path at a range R, an altitude H, and a speed of V. What should be the elevation, 0 (angle above the horizontal) of your gun to hit the target? The problem is illustrated in the figure below. Since the projectile is accelerating downward under the influence of gravity, it follows a parabolic path. The aircraft is assumed to be following a straight-line horizontal path at constant speed. The trajectories of the projectile and the target will intersect at some point (x.y), provided that the launch angle is high enough. For a successful intercept, the projectile and target must reach the intercept point simultaneously Intercept Point a9.81 m/s Not to scale The kinematic equations describing the motion of the projectile and the target are as follows: For the projectile: y1 (t) Vm (sin 8) t-gt XI (t)-Yn (cos ) t For the aircraft: Y2-H For a hit, must have: x1 x2,y1-y2 Solving the first equation for t Tasks Write a function that calculates the launch angle, given the target range, altitude and velocity and cannon's muzzle velocity 1. Function specifications Input arguments: Range (R) in meters; Altitude (H) in meters; Target velocity (V) in m/s; Muzzle velocity (Vm) in m/s,INOTE: for compatibility with the checker, the arguments must be in this order and the tolerance must be 0.001 or better.] Output argument: The required launch angle in degrees. Use the following test case to validate your function: Rs 7,000 m; H 2,500 m; V-225 m/s; Vrn 1,000 m/s-) -25.650 2. Write a script to apply your function from task 1 to a set of provided target data Load the target data from the provided Excel file, targets.xlsx, the command (you don't have to use the variable name data - it can be whatever you like): a. into a matrix using data = x1sread ( 'targets .xlsx' ) ; .Each row of the data file contains the parameters for one target, in the following order: Range, Altitude, Velocity . Use a fixed value of 1,000 m/s for Vm b. Loop over the targets, calling the iterative solver function to determine the launch angle for each one Extract the parameters from the data array that you created in 2a; do not hard-code the numbers or the number of targets. (In other words, your program should work just as well if applied to a different data file.) Store the solutions (the calculated launch angles) in a row vector called angles (This is for compatibility with the checker.) Background: Iterative Solution to Mechanics Problems In introductory physics, most problems can be solved algebraically, partly because simplifying assumptions are used (no air resistance, small-angle approximation, etc.). When more detailed and realistic descriptions of the physics are incorporated into a problem, it may not be solvable in closed form. In cases like this, numerical solutions are sought. One technique for solving problems numerically is iteration. An iterative solution proceeds as follows: make an initial assumption, or guess, about the solution apply this assumption to generate a first, approximate solution adopt the approximate solution as the new guess, and use it to calculate a second approximation continue this process, generating better and better approximations, until the solution converges - that is, until the next iteration does not change the solution significantly . Depending on the complexity of the problem, iterative solutions may or may not produce an accurate solution efficiently, independent of the initial guess. The problems that we are tackling in this assignment are amenable to an iterative approach- if your code is correct, you will get a good solution in a small number of iterations, regardless of your initial guess. Example: Accounting for the finite speed of sound Consider this problem A man drops a rock into a well. He hears the sound of the splash 2.40 s after he releases the rock from rest. How far below the top of the well is the surface of the water? The reason that this problem is not as trivial as it seems is that 2.40 s is not the time that it takes for the rock to hit the water, but rather the time that it takes for the echo to reach the top of the well. That is, it is the sum of the time for the rock to hit the water (t1) and the time for the echo to travel to the top of the well (t2). Although this problem can in fact be solved exactly, it is nonetheless a good example to illustrate the iterative method First approximation The starting assumption is that the time for the echo to travel to the top of the well is small compared to the time for the rock to hit the water. The first approximation for the depth of the well can therefore be calculated from simple kinematics as follows: Serwayand Jewett, Physics for Scientists and Engineers, 8th ed., problem 2.67 where g 9.81 m/s2 is the acceleration due to gravity at the surface of the earth. Since the rock is dropped, not thrown, o 0, and H-Aya gt-(9.81 m/s2) (2.40s)2 28.25 m Second approximation Given this initial estimate for the depth of the well, the time for the echo to propagate to the top, assuming speed of sound 340 m/s, is t2- (28.25 m)/340 m/s)- 0.083 This implies that the time for the rock to reach the water was not the full 2.40 s, but rather t1-2.40 s0.083s-2.317 s Therefore, a better estimate of the depth of the well is Hgt (9.81 m/s2) (2.317s)-26.33 m Of course, the process does not stop here. Based on this improved estimate for H, we can get a better estimate for t2, which leads to an even better estimate for H, and so on. Eventually, assuming that the calculation converges, the difference between subsequent estimates of H will be negligibly small. In this example, H converges within 5 iterations to a final value of 26.45 m. A logical diagram (flow chart) of this algorithm is shown below. This algorithm can be implemented using a while loop. The loop terminates when two subsequent approximations for the result (H and Hi) differ by less than a specified tolerance (TOL) Application 6: Iteration Designed to test skills with: looping, user-defined functions, iteration For this assignment, submit ALL of the following: function file (.m), script file (.m), and text ENGR 1221 output file (.txt) %Set parameter values Vs 340 m/s t 2.40 s %Initialize guesses 2-0, H10 %Calculate t1 %Calculate H H-H TOL? The Project: You are asked to use an iterative method to solve the following problem: You are manning an anti-aircraft gun with a muzzle velocity, V: An enemy aircraft is approaching on a horizontal path at a range R, an altitude H, and a speed of V. What should be the elevation, 0 (angle above the horizontal) of your gun to hit the target? The problem is illustrated in the figure below. Since the projectile is accelerating downward under the influence of gravity, it follows a parabolic path. The aircraft is assumed to be following a straight-line horizontal path at constant speed. The trajectories of the projectile and the target will intersect at some point (x.y), provided that the launch angle is high enough. For a successful intercept, the projectile and target must reach the intercept point simultaneously Intercept Point a9.81 m/s Not to scale The kinematic equations describing the motion of the projectile and the target are as follows: For the projectile: y1 (t) Vm (sin 8) t-gt XI (t)-Yn (cos ) t For the aircraft: Y2-H For a hit, must have: x1 x2,y1-y2 Solving the first equation for t Tasks Write a function that calculates the launch angle, given the target range, altitude and velocity and cannon's muzzle velocity 1. Function specifications Input arguments: Range (R) in meters; Altitude (H) in meters; Target velocity (V) in m/s; Muzzle velocity (Vm) in m/s,INOTE: for compatibility with the checker, the arguments must be in this order and the tolerance must be 0.001 or better.] Output argument: The required launch angle in degrees. Use the following test case to validate your function: Rs 7,000 m; H 2,500 m; V-225 m/s; Vrn 1,000 m/s-) -25.650 2. Write a script to apply your function from task 1 to a set of provided target data Load the target data from the provided Excel file, targets.xlsx, the command (you don't have to use the variable name data - it can be whatever you like): a. into a matrix using data = x1sread ( 'targets .xlsx' ) ; .Each row of the data file contains the parameters for one target, in the following order: Range, Altitude, Velocity . Use a fixed value of 1,000 m/s for Vm b. Loop over the targets, calling the iterative solver function to determine the launch angle for each one Extract the parameters from the data array that you created in 2a; do not hard-code the numbers or the number of targets. (In other words, your program should work just as well if applied to a different data file.) Store the solutions (the calculated launch angles) in a row vector called angles (This is for compatibility with the checker.)

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions