{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW1_Solutions.pdf

# HW1_Solutions.pdf - ENED 1091 Engineering Models II...

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

ENED 1091: Engineering Models II Homework Assignment #1 SOLUTIONS Problem 1: Array Indexing For this problem, you will need to download the HW7.mat file from Blackboard. Drop it in your current MATLAB folder then type: load HW7 at the MATLAB command prompt. You should now have the following three variables (x, y, and M) in your workspace with the values shown below. Don’t make any m odifications to these variables. x = 4 5 -1 5 3 -2 0 2 5 5 -1 5 5 3 4 y = -1 5 5 4 5 3 -2 4 5 3 4 3 1 3 -1 M = 2 2 3 2 -4 -5 -2 7 3 0 -2 5 -3 -2 5 -5 -5 0 2 -2 -4 -1 -1 2 1 4 -1 2 -4 -3 For all parts of this problem, don’t put a semicolon at the end of your command so you can copy the results as well as your MATLAB command. a) What MATLAB command will pull out entries 7 thru 12 in vector, x, and store them in a vector called a? Command and Results: >> a = x(7:12) a = 0 2 5 5 -1 5 b) What MATLAB command will pull out every other entry of the vector, x, starting at entry 4 and ending at entry 12 and store these entries in a vector called b? Command and Results: >> b = x(4:2:12) b = 5 -2 2 5 5 c) What MATLAB command will pull out the7 in matrix, M, and store it in a scalar variable called c? Command and Results: >> c = M(2,3) c = 7

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

View Full Document