{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm 1 07' - 1 MATLAB nuts and bolts The following...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
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 1with the basics of MATLAB operations. In each part of this problem, you will be given a word description of an operation, and your task is to 1write a short code fragment that implements the operation. o Create a folder in the director};r C:\Ternp, and use it to store all your files for this test. I Launeh MATLAB. I Open the MATLAB editor and create a SCRIPT FILE ealled Prob1.m. I For each part of this problem, start your answer with two lines in the script file. For example, for Port A, enter the node lines: K ===: ====== ====== ======= === K PART A Part A [5 pts] Part B [5 pts] Part C [5 pts] Part D [5 pts) Part E [8 pts] Create a vector PurtA containing every eleventh number starting at 10 going to 12D. Create a vector :r. that has five equally spaced elements in the interval CI 4:: :r «:1: 2w. Create another vector Part3 so that for each element 2:; in it: there is a corresponding Part3; that is defined by Part3; = cos[3:rfle_H 2173' where H = ? Define a column vector :4: with elements 3= 9, 5= 5, l and a second column vector y with elements 2, l: 4: ti, 2. Define a variable Part0 so that Part0 is equal to 1 if all elements in IE and y are such that I = 23:: and I] otherwise. Define a vector temps that is contains the following elements: 31, 22, 38, =15, 2E], 32. Define a vector PnTtD that contains all the values in temps between 35 and 35. A function of one variable is defined as follows: 2 HI) = (if/ac) 1Write a short set of symbolic toolbox MATLAB commands that ends with computing a variable PoTtE that is the maximum value of f in the interval I] 11'. IE 11 5. Make a graph of f in the same interval to test your code. [Creating the graph should be part of your answer.) Part F [8 pts] A description Mt] of a type of ballistic niotion where frictional force clue to air resistance is proportional to the speed of the object is as follows: duh. _ do. ca"! _ H alt where g and ls: are constants. rFhe initial conditions are fl=Illa:lilwhent=fl {it Write MA’I‘LAB code that will set a variable PortF to the solution of the differential equation above. 2 Maxf Min Suppose you have a string of length L. You cut ofi a part of the string of length c and construct a circle from it. Using the part of the string that is left over, you construct a square. Determine the length of c that will maximize the combined area of the square and the circle. 'Write a function P-rohfl that takes one numerical input: the length of the string L. The function will return one numerical output: the length of string that is initiall}r cut offI c that will maximize the total area. 3 Vectors In one of your homework problems, you learned that a wag.r to implement “mat-hfphjrsics vectors’1 is by using MATLAB vectors. lEI-Jvzplicitlj,r in your homework, you used cell— bv—cell addition of vectors to implement addition of “mathfphvsics vectors.’1 Another useful operation on “math—physics1 vectors is the dot product. One in— terpretation of the dot product of two vectors [1' and E! is the projection of E: on Er. Geometrically, the dot product can be computed by the following: 5.3: |a| saw) where I9 is the angle between the two vectors. And the operation with the vertical lines is the “length of the vector.” {Be careful to note this is NOT the MATLAB sense of length: the number of elements in a vector. It is the linear length of a “Loathfphjrsics’1 vector.) 'Write a function ProbS that takes two inputs: the MATLAB vector representation of two, two dimensional vectors. Your function should compute and return the angle {in radians) between the two input vectors. {The inverse cosine function in MATLAB is acos.) 4 Content Addressing You are the PR Chief of the SleekAndFast auto sales company. Your CEO has asked you to develop a way for customers to specify the lowest gas mileage they would consider in a car purchase, and the highest purchase price they would consider. After giving these two values, the customers should be handed a set of pictures and descriptions for all cars in the inventory at SleekAndFast that meet the customer specs. You organise the data for your inventory into a table like the one below. The first column is the inventory number, the second is the purchase price, the third is the gas mileage, and the last is the gross weight. #IDZ $24,ooo ea mpg 3429 lbs #QTI $1s,ooo 35 mpg can? lbs # 322 $3s,ooo es mpg 31o: lbs #7515 $ee,ooo 31 mpg eeso lbs #541 $35,ooo 14 mpg 4218 lbs # 871 $ 38,00!) 21 mpg 352? lbs You first goal is to write a MATLAB function to find the inventory number of all cars that meet the customer constraints. Once you have those inventory numbers, you can write a short program to display the pictures and full descriptions of the cars to hand to a customer. Write a function Probe that inputs five values in the order shown below: ...
View Full Document

{[ snackBarMessage ]}