HW8_ENED1090_Autumn_2016(1)

# HW8_ENED1090_Autumn_2016(1) - Homework#8 ENED 1090...

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

Homework #8 ENED 1090: Engineering Models I Homework Assignment #8 Due: Friday, November 11, 2016 at 5:00pm Problem 1: Work through the following MATLAB code by hand and fill in the table. Then check your results using MATLAB. M = [-1 5 2; 6 4 -1; 0 3 10]; [nrows, ncols] = size(M); S = zeros(1,nrows); for row = 1:nrows S(row) = M(row,1); for col = 2:ncols if M(row,col) > S(row) S(row) = M(row,col); end end end S Before Loops [ 0 0 0] row col 1 -- [-1 0 0] 1 2 [-1 0 0] 1 3 [-1 0 0] 2 -- [-1 6 0] 2 2 [-1 4 0] 2 3 [-1 -1 0] 3 -- [-1 -1 0] 3 2 [-1 -1 0] 3 3 [-1 -1 0] Note: The dash (--) in the column labeled col indicates just prior to entering the inner loop

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

View Full Document
Homework #8 Problem 2: Work through the following MATLAB code by hand and fill out the table. Again, check your answers using MATLAB. p = [0 2 3 4]; M = zeros(2,4); [nrows, ncols] = size(M); for row = 1:nrows for col = 1:ncols M(row,col) = row*2^p(col); end end row col M Before Loops 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 2 1 4 0 0 0 0 0 0 1 3 1 4 8 0 0 0 0 0 1 4 1 4 8 16 0 0 0 0 2 1 1 4 8 16 2 0 0 0 2 2 1 4 8 16 2 8 0 0 2 3 1 4 8 16 2 8 16 0
Homework #8 Problem 3: For this problem, you will need to download the HW8.mat file. Save it in your current MATLAB folder. At the MATLAB command prompt, enter the following: >> load HW8 You should see two 3x4 matrices, A and B in your workspace. Create a script file and include the command: load HW8 in your script. Use nested for loops to accomplish the following: Create a new matrix C that has entries with the minimum of A and B (i.e., if A(r,c) is smaller than B(r,c) then C(r,c) equals A(r,c), if B(r,c) is smaller that A(r,c) then C(r,c) equals B(r,c), otherwise C(r,c) = B(r,c) = A(r,c)).

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern