Ch E 310 - Fall 10 - Lecture 7

Ch E 310 - Fall 10 - Lecture 7 - Lecture 7 September 14,...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 7 – September 14, 2010 Agenda: Additional useful MATLAB functions Successive Over/Under Relaxation in Iterative Methods (Jacobi or Gauss-Seidel) In-Class Exercise 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
MATLAB: More Useful Functions [Y,I] = max(x) returns the largest value(s) in x >> [Y,I] = max(x) % Y = maxes, I = locations Y = 8 9 7 I = 1 3 2 >> [Y,I] = max(x,[],2) % find row maxes Y = 8 7 9 I = 1 3 2
Background image of page 2
MATLAB: More Useful Functions [Y,I] = min(x,[],1) returns the smallest value(s) in x median(x) calculates the median value(s) of x >> [Y,I] = min(x) Y = 3 1 2 I = 2 1 3 >> median(x) % median of each column ans = 4 5 6 >> median(x,2) % median of each row ans = 6 5 4
Background image of page 3

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

View Full DocumentRight Arrow Icon
MATLAB: More Useful Functions [r,c] = size(x) returns number of rows and columns in x mean(x) calculates the average value(s) of x >> [r,c] = size(x) r = 3 c = 3 >> mean(x) % mean of each column ans = 5 5 5 >> mean(x,2) % mean of each row ans = 5 5 5
Background image of page 4
MATLAB: More Useful Functions sum(x) calculates the sum of the elements in x prod(x) calculates the product of the elements in x >> sum(x) % sum of each column ans = 15 15 15 >> sum(x,2) % sum of each row ans = 15 15 15 >> prod(x) % product of each column ans = 96 45 84 >> prod(x,2) % product of each column ans = 48 105 72
Background image of page 5

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

View Full DocumentRight Arrow Icon
MATLAB: More Useful Functions std(x) calculates the standard deviation of the elements in x var(x) calculates the variance of the elements in x >> std(x) % standard deviation of columns ans = 2.6458 4.0000 2.6458 >> std(x,[],2) % standard deviation of rows ans = 3.6056 2.0000 3.6056 >> var(x) % variance of columns ans = 7 16 7 >> var(x,[],2) % variance of rows ans = 13 4 13
Background image of page 6
MATLAB: More Useful Functions pause(n) halts the current process for n seconds pause used alone waits for the user to hit a key to continue One particularly useful application of pause is for debugging By putting a pause command in the code, you can assess the output during a loop one iteration at a time
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

Ch E 310 - Fall 10 - Lecture 7 - Lecture 7 September 14,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online