This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Jan. 25, 2010 Homework 1 6.094: Introduction to Matlab Homework 1 This homework is designed to teach you to think in terms of matrices and vectors because this is how Matlab organizes data. You will find that complicated operations can often be done with one or two lines of code if you use appropriate functions and have the data stored in an appropriate structure. The other purpose of this homework is to make you comfortable with using help to learn about new functions. The names of the functions you’ll need to look up are provided in bold where needed. Homework must be submitted on the stellar website before the start of the next class. What to turn in: Copy the text from your scripts and paste it into a document. If a question asks you to plot or display something to the screen, also include the plot and screen output your code generates. Submit either a *.doc or *.pdf file. For problems 17, write a script called shortProblems.m and put all the commands in it. Separate and label different problems using comments. 1. Scalar variables. Make the following variables a. a = 10 b. b = 2.5 × 10 23 c. c = 2 + 3 i , where i is the imaginary number d. d = e j 2 π /3 , where j is the imaginary number and e is Euler’s number (use exp , pi ) 2. Vector variables. Make the following variables a. aVec = [ 3.14 15 9 26 ] 2.71 b. bVec = 8 28 182 c. cVec = [ 5 4.8 ⋯ − 4.8 − 5 ] (all the numbers from 5 to 5 in increments of 0.2) d. dVec = 10 0 10 0.01 ⋯ 10 0.99 10 1 (logarithmically spaced numbers between 1 and 10, use logspace , make sure you get the length right!) e. eVec = Hello ( eVec is a string, which is a vector of characters) 3. Matrix variables. Make the following variables 2 ⋯ 2 a. aMat = ⋮ ⋱ ⋮ a 9x9 matrix full of 2’s (use ones or zeros ) 2 ⋯ 2 1 Jan. 25, 2010 Homework 1 6.094: Introduction to Matlab 1 0 ⋯ 0 ⋱ 0 ⋱ b. bMat = ⋮ 5 0 ⋮ a 9x9 matrix of all zeros, but with the values ⋱ 0 ⋱ 0 ⋯ 1 [ 1 2 3 4 5 4 3 2 1 ] on the main diagonal (use zeros , diag ). 1 11 ⋯ 91 2 12 ⋱ 92 c. cMat = a 10x10 matrix where the vector 1:100 runs down the ⋮ ⋮ ⋱ ⋮ 10 20 ⋯ 100 columns (use reshape ). NaN NaN NaN NaN d. dMat = NaN NaN NaN NaN a 3x4 NaN matrix (use nan ) NaN NaN NaN NaN 13 − 1 5 e. eMat = − 22 10 − 87 f. Make fMat be a 5x3 matrix of random integers with values on the range 3 to 3 (use rand and floor or ceil ) 4. Scalar equations. Using the variables created in 1, calculate x , y , and z ....
View
Full Document
 Spring '11
 Smith
 matlab, Summation

Click to edit the document details