Homework 2

# Homework 2 - EGM 3344 Sorting Number 190 Problem Set 2...

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

EGM 3344 Sorting Number: 190 Problem Set: 2 Problems completed: 2.3, 2.6, 2.8, 2.9, 2.11, 2.13, 2.20, 2.51, 2.54, 2.61, 2.63, 3.12, 3.15, 3.23, 3.24, 4.1, 4.4, 4.14, 4.18

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

View Full Document
Problem 2.3 Code and Solution: %Problem 2.3 %linspace creates an array of 6 values equally spaced %with the first value 0 and the last value 10 x = linspace(0,10,6) n = length(x); A = zeros(2,n); A(1,:) = 3*x; A(2,:) = 5*x - 20; A x = 0 2 4 6 8 10 A = 0 6 12 18 24 30 -20 -10 0 10 20 30 Problem 2.6 Code and Solution:
%Problem 2.6 %Matrix A A = [3 7 -4 12;-5 9 10 2;6 13 8 11;15 5 4 1] %Matrix B equivalent to columns 2,3,4 of Matrix A B = zeros(4,3); B(1:4,1) = A(1:4,2); B(1:4,2) = A(1:4,3); B(1:4,3) = A(1:4,4); B %Matrix C equivalent to rows 2,3,4 of Matrix A C = zeros(3,4); C(1,1:4) = A(2,1:4); C(2,1:4) = A(3,1:4); C(3,1:4) = A(4,1:4); C %Matrix D equivalent to columns 2,3,4 of rows 1 and 2 of Matrix A D = zeros(2,3); D(1,1:3) = A(1,2:4); D(2,1:3) = A(2,2:4); D A = 3 7 -4 12 -5 9 10 2 6 13 8 11 15 5 4 1 B = 7 -4 12 9 10 2 13 8 11 5 4 1 C = -5 9 10 2 6 13 8 11 15 5 4 1 D = 7 -4 12 9 10 2 Problem 2.8 Code and Solution:

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

View Full Document
%Problem 2.8 %Matrix A A = [3 7 -4 12;-5 9 10 2;6 13 8 11;15 5 4 1]; %Max and min values of each column maxcolumn = max(A) mincolumn = min(A) %Max and min values of each row maxrow = max(A') minrow = min(A') maxcolumn = 15 13 10 12 mincolumn = -5 5 -4 1 maxrow = 12 10 13 15 minrow = -4 -5 6 1 Problem 2.9 Code and Solution:
%Problem 2.9 %Matrix A A = [3 7 -4 12;-5 9 10 2;6 13 8 11;15 5 4 1]; %Sorts the values in the columns of Matrix A in ascending order B = sort(A) %Sorts the values in the rows of Matrix A in ascending order C = sort(A'); C = C' %Sums the columns and rows of Matrix A D = sum(A) E = sum(A') B = -5 5 -4 1 3 7 4 2 6 9 8 11 15 13 10 12 C = -4 3 7 12 -5 2 9 10 6 8 11 13 1 4 5 15 D = 19 34 18 26 E = 18 16 38 25 Problem 2.11 Code and Solution:

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

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

## This note was uploaded on 09/05/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

### Page1 / 21

Homework 2 - EGM 3344 Sorting Number 190 Problem Set 2...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online