{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm 06' - 1 MATLAB “Nuts and Bolts” The following...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 MATLAB “Nuts and Bolts” The following questions are to test your understanding and skill at MATLAB nuts and bolts operations. In each part of this problem, you will be given a word descrip- tion of an operation, and your task is to write a short code fragment that implements the operation. Create a folder on your desktop, and use it to store all your files for this test. Launch MATLAB. Open the MATLAB editor, create a SCRIPT FILE called Prob1.m. For each part of this problem, start your answer with two lines in the script file. For example, for Part A, enter code lines of Other than these lines at the start of your answer for each question, you need not include any other comments in your answer to this question. Part A (7 pts.) Part B [7 pts.) Part C (7 pts.) Part D (7 pts.) Create a vector PcrtA containing every sixth number from 1 to 102. Set the last three elements of Parts]. to be 2010. Create a vector m that has 25 equally spaced elements in the interval 1 g a: g arr. Create another vector Part3 so that for each element x, in 3, there is a corresponding Part3.- that is defined by the following. 3 103%) P t3, = — ar (3 + 1,)‘1 + 4exp(:r,) Note that the log symbol above is the base 10 log. Define a vector .7: and a second vector y as the following: x=[3;9;5;551] If: [2; 1; 4; 5:. 2] Now define a vector Part0 to be the result of a computation such that Part0 is 1 if each elements of y is double the corresponding element in 9:, and 0 otherwise. Define a vector prices as the following: [21 24 29 19 31 25] prices Now set another vector pvtceOutstdcjtijS which contains all the values in prices that are outside the interval {24, 28}. Note you must use relationalflogical operators in your answer! Part E (7 pts.) Part F (7 pts) COnsider a function fir) defined as are) = 1/5 exp (-233) Write a short set of symbolic commands that ends with computing a variable Pas-1E, the max value of fix) in the interval 0 s m g 2|]. Create a plot of f (9;) to test your answer. If you do not use symbolic operations to obtain the answer to this question, you will receive no credit for this problem. Consider the differential equation fl _ _ _ km s2 ' g a: where g and k are constants. Solve the second order differential equation above analytically using the symbolic toolbox for initial condtions: dh E—fl, h—thent—fl Put your answer for the solution to the differential equation into a variable PartF. 2 Symbolic Problem Solving A vehicle is traveling in a two dimensional space on a road defined by y = —D.5r. + 8 where r and y are in mile units east and north of some coordinate system origin. The vehicle picks up a signal from a beacon that is known to be 5 miles away and andalsokuowntobelocatedatz=3andy=4. Where is the vehicle located in the icy-coordinate system at the time it gets this signal from the beacon? Use MATLAB symbolic functions to produce the solution. Upload your solution as a function you name Prob2, which takes no input and returns following three outputs in the order listed below: a a numerical vector of x—coordinate values that satisfy the problem requirements, a a numerical vector of corresponding y-coordinate values, and u a numerical vector of corresponding distance values (distance from beacon to vehicle) - this is a test to be sure the function is working right. Each value in this vector should be 5 miles. All computations should be done by using the symbolic toolbox. At the end of your function convert from symbolic solutions to numerical solutions before returning the results. Do not forget to include proper comments in your function. You might find drawing a sketch to be of use. 3 Vector Operations Write a MTLAB function named Prob3 that computes the weighted average of a list of grades. The first input to the function is a vector of N grades, each between I] and 100. The second input is a vector of weights, each corresponding to a grade in the first input. The weights are assumed to be between I] and 1 and all together to sum to 1. The function returns a single scalar output that is the weighted average: each grade is multiplied by its weight and then all these products are summed. ...
View Full Document

{[ snackBarMessage ]}