Fill This Form To Receive Instant Help

#### AERO 3970 - Aerospace Applications of MATLAB Homework 3 Write a script file to perform the following c alculations

###### Mechanical Engineering

AERO 3970 - Aerospace Applications of MATLAB

Homework 3

Write a script file to perform the following c alculations. Output answers as indicated in each problem statement. All intermediary calculations should be suppressed with a semi-colon. Save

the file as L astName_Hwk1.m. Remember to format your script file according to the guidelines described in the syllabus. Submit your script file and any supporting files (functions, data, etc.) as a single zipped folder via Canvas. I should be able to open your folder and run your script without any errors.

1. Standard Atmosphere Interpolation [10 Pts]

The relation between geopotential h and geometric altitude hG is given by

h = r hG where r = 6.356733 × 106 m (1) r +hG

Recall, that the standard atmosphere is divided into a series of gradient and isothermal regions. (See Chapter 3 of Introduction to Flight by John D. Anderson for a review of the standard atmosphere). The first gradient region extends over the range 0 km ≤ h 11 km. Over this range the temperature, pressure, and density are governed by

T =Ts +a(h hs)                 (2)

ρ           T −{[g0/(aR)]+1}

=              (3) ρs     Ts

p           T −g0/(aR)

=         (4) ps     Ts

where a = −6.5 × 10−3 Km−1, hs = 0 km, Ts = 288.16 K, ρs = 1.2250 kgm−3, ps = 1.01325 × 105 Pa, R = 287 Jkg−1 K−1, and g0 = 9.8 ms−2. The next isothermal region is defined over the range 11 km ≤ h 25 km. Here the temperature, pressure, and density are governed by

# T =T1                                 (5)

ρ

= exp {−[g0/(RT)](h h1)}       (6) ρ1 p

= exp {−[g0/(RT)](h h1)}       (7) p1

where h1 = 11 km, T1 = 216.66 K, p1 = 2.26 × 104 Pa, and ρ1 = 0.367 kgm−3.

1. Write a function that will calculate and return the temperature, pressure, and densitygiven a geometric altitude, hG. (Bonus [1 Pt]: Construct the function in such a way that a vector of altitudes of any length can be passed and the corresponding arrays of T, p, and ρ are returned.) With your function, calculate the values of T, p, and ρ at hG = 1250, 8562, 12324, and 19956 m.

Auburn University, Department of Aerospace Engineering

AERO 3970 - Homework 3                                                                   Fall 2021

1. Based on the table look-up example that was covered in class, create a function thataccepts a vector of x values, a matrix of y values where each column corresponds to a different function and each row corresponds to an x value, and a vector of query points. The function should return an array of interpolated values at the query points using linear interpolation.
2. Read in the included standard atmosphere .csv file using dlmread or csvread. The data is arranged such that the first column contains the geometric altitude in km, the second temperature in K, the third pressure in Pa, and the last the density in kgm−3. Using this data and the function from part (b) interpolate the values of T, p, and ρ at the geometric altitudes given in part (a).
3. Use interp1 and the data read in part (c) to obtain interpolated values for T, p, and ρ at the same altitudes using the ’pchip’ method.
4. Output well formatted, clean tables of the results. You should output three tables. Oneeach for T, p, and ρ with 4 row labels indicating the altitude and 4 column labels. Format the numbers in scientific notation with 4 decimal points (this is equivalent to

format shortE).

1. Thought Question: In a short code comment, which interpolation method was the most accurate as compared to the direct calculation? Why?

2. Search Algorithm Comparisons [5 Pts]

In class, we mentioned that there are several ways to search for a value within an array. For interpolation we desired the index of the element whose value directly preceded the requested interpolation point. There are two basic types of searches that are commonly used. Your task is to implement each type of search described below and compare the time it takes to find a set of requested values.

1. Linear Search: For the linear search, you should iterate over each element in the array comparing the value to the desired value..
1. Read in the provided vector using load. The variable contained in the .mat file is named vec.
2. Implement a linear search to find the following values: 313176, 1403219, 2303140,3949712. Start the search from scratch for each value. Also, output the index at which each value was found in a clearly labeled statement.
3. Use tic and toc to determine how long it takes to find all of the requested values and output the result to the command window.
2. Binary Search: A binary search works off the assumption that the data is sorted from lowest to highest. Each iteration within the search, compares the median value to the requested value. If the median is less than the requested, then the requested value lies in the upper half of the original range and the range is reset with the median as the lowest value. If the median is greater than the requested, then the requested value lies in the lower half of the original range and the range is reset with the median as the highest value. If the median is equal to the requested, then the location has been found. This series of split, compare, reduce is repeated until the requested value is found.

Auburn University, Aerospace Engineering Department

AERO 3970 - Homework 3                                                                   Fall 2021

1. Use the same vector that was loaded in part (a)
2. For each requested value, implement a binary search to determine its location.
3. Use tic and toc to time how long it takes to find all of the requested values and output the result to the command window.
1. find: Use the built-in MATLAB function find to determine the location of the values in part (a). Determine the total time to find all four values and print the locations in a clearly labeled statement. (Hint: Each method should report the same location for a given value. If not, something is wrong.)
2. Thought Question: In a code comment, which method was faster? Why?

Auburn University, Aerospace Engineering Department