EGR106 Assignment # 2, Part 1

Total Page:16

File Type:pdf, Size:1020Kb

EGR106 Assignment # 2, Part 1

EGR106 Assignment # 2, part 1 Due Feb. 12, 2008

Instructions – The problems in this assignment ask you to create and manipulate various arrays. Rather than just doing so at the command prompt, you are to write a script file to implement all of the requested operations. Please do the following:  Name your script using your last name followed by the assignment number, e.g. brown2.m.  The first command in your script should be a disp command to show your name and section number.  Do the problems in order.  Use pause and clc in between problems for a nice presentation. Pause allows me to view the output one problem at a time; clc erases the command window so that it is obvious what the new material is. A sample script that does most of these objectives appears on the course website (file HW2_sample.m).

When you get this script working (and please check it before sending it to me…..the most common problem students have at this point in EGR106 is that some minor error causes their submission to fail to execute), send this single file to [email protected]

1. Create a column vector with the elements 28, log(5), cos(60○), and 66.1. Create a row vector with the entries 22, π, ⅞, and 0. Create a 3 row by 5 column matrix with any non-trivial entries (you can select the values). Call this matrix A (in other words, it is a variable in the workspace). All of these are just brute force constructions.

2. Start by creating a 3-element column vector, called b, with entries 8, 3, and 7. Create c as a 5-element row vector with entries 0, 88, 11, 3, and 7. Using concatenation, create a 3 by 7 matrix D whose first and last columns are b, with A (from problem 1) in the middle. Finally, create a 5 by 5 matrix E whose first and last rows are c, with A again in the middle. Show b, c, D, and E in the command window.

3. Create a row vector whose first element is 20, with elements decreasing in increments of 5, with the last element being -60. (Use the colon operator.)

4. Create the variable F, a 3 by 3 matrix, from the center of matrix E from problem 2. (Note, do not use brute force construction; you are to use addressing on E.)

5. Create the variable G, a 2 by 3 matrix, from the first and third rows, first, second, and fourth columns of matrix E from problem 2. (Again, you are to use addressing on E.)

Recommended publications