Вы находитесь на странице: 1из 2

ME2315

Computer-Aided Analysis, Fall 2013 HW #1 due 9/9/2013 page 1 of 2 Topic: MATLAB review Read & do as tutorial: Ch 2, including the shaded pages (case study). Read Ch 3.1, 3.3.2 (for loop only) Please follow the posted guidelines for creating and naming M-files. You will have one M-file per problem. Bring hand work to lab Problems from your text: HW1_1 problem 2.11. Upload M-file and jpg of the graph, named HW1_1.jpg HW1_2 problem 2.16 a&b Additional problems: HW1_3 Two trains each leave their respective stations and approach each other on separate tracks. One is travelling east at 12 mph and the other is travelling west at 13 mph. The stations are 100 miles apart. Write a MATLAB script file to compute and display the time at which the trains meet, and the distance each train has travelled. Use good programming techniquedefine variables for parameters at the top of the file, and solve using these variables. HW1_4 Given the following MATLAB variables, determine by hand what appears in the Command Window as commands a-j are entered sequentially. What are the final values of all the variables? To submit this assignment on Bb, enter the arrays & commands into one M-file. Comment out any commands that cause an error. = = = a) b) c) d) e) a(3) f) [a 2*a] b.^2 g) g=a(2:end)/c c=A(1,1)^1/2 h) a(2)=[] D=[A(3,1:2) b] i) A=[A;a] [b;b]+a j) j=A(1:2,3)+b

HW1_5 Given the following MATLAB variables, determine by hand what appears in the Command Window as instructions a-e are followed sequentially. What are the final values of all the variables? Generate the MATLAB commands that follow the instructions. To submit this assignment on Bb, enter the arrays & your commands into one M-file. = = = a) Square the third element of a. Store the result into c b) Find the square root of the last element of b, and place this value as the first element of array a c) Find the minimum of all the elements in A d) Insert c in the middle of array b e) Append the middle 3 elements of array a as the last column of matrix A f) Remove the first row of matrix A

ME2315 Computer-Aided Analysis, Fall 2013 HW #1 due 9/9/2013 page 2 of 2 HW1_6 Using colon notation and the linspace function a. Use the linspace function to create vectors identical to the following created with colon notation: i) x = 1 : 2.5 : 12.4 ii) y = 5:8:38 iii) z = -3:1.5:4 b. Use colon notation to create vectors identical to the following created with the linspace function: i) t = linspace(-2.5, 5, 10) ii) v = linspace(-3, 8, 16) HW1_7 Array Operation Arrays are given as x = [1 2 4 6], y = [pi/4 pi/2 3pi/4 pi] Use MATLAB to compute

z=

3x 2 sin( y ) + 1 / x xy + 4

a) Show the long way to calculate z (You will have 4 lines.) b) Use a for loop to calculate z. By hand, fill in the trace table below for each repetition. c) Use vectorization to calculate z.
i z

Вам также может понравиться