# Week02 - Rutgers University School of Engineering Fall 2011 14:440:127 Introduction to Computers for Engineers Sophocles J Orfanidis ECE Department

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

Rutgers University School of Engineering Fall 2011 14:440:127 - Introduction to Computers for Engineers Sophocles J. Orfanidis ECE Department [email protected] week 2

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

View Full Document
Week 1 - Basics – variables, arrays, matrices, plotting (ch. 2 & 3) Week 2 - Basics – operators, functions, program flow (ch. 2 & 3) Week 3 - Matrices (ch. 4) Week 4 - Plotting – 2D and 3D plots (ch. 5) Week 5 - User-defined functions (ch. 6) Week 6 - Input-output formatting – fprintf, sprintf (ch. 7) Week 7 - Program flow control & relational operators (ch. 8) Week 8 - Matrix algebra – solving linear equations (ch. 9) Week 9 - Structures & cell arrays (ch. 10) Week 10 - Symbolic math (ch. 11) Week 11 - Numerical methods – data fitting (ch. 12) Week 12 – Selected topics Weekly Topics Textbook: H. Moore, MATLAB for Engineers , 2 nd ed., Prentice Hall, 2009
1. MATLAB desktop 2. MATLAB editor 3. Getting help 4. Variables, built-in constants, keywords 5. Numbers and formats 6. Arrays and matrices 7. Operators and expressions 8. Functions 9. Basic plotting 10. Function maxima and minima 11. Relational and logical operators 12. Program flow control 13. Matrix algebra and linear equations MATLAB Basics These should be enough to get you started. We will explore them further, as well as other topics, in the rest of the course. week 1 week 2

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

View Full Document
6. Arrays and Matrices arrays and matrices are the most important data objects in MATLAB Last week we discussed one-dimensional arrays, i.e., column or row vectors. Next, we discuss matrices, which are two-dimensional arrays. We will explore them further in Chapters 4 & 9.
>> A = [1 2 3; 2 0 4; 0 8 5] A = 1 2 3 2 0 4 0 8 5 >> size(A) % [N,M] = size(A), NxM matrix ans = 3 3 matrix indexing convention

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

View Full Document
accessing matrix elements: >> A(1,1) % 11 matrix element ans = 1 >> A(2,3) % 23 matrix element ans = 4 >> A(:,2) % second column ans = 2 0 8 >> A(3,:) % third row ans = 0 8 5
>> A = [1 2 3 4; 2 0 5 6; 0 8 7 9] % size 3x4 A = 1 2 3 4 2 0 5 6 0 8 7 9 >> A' % size 4x3 ans = 1 2 0 2 0 8 3 5 7 4 6 9 transposing a matrix: rows become columns and vice versa => transposition operation

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

View Full Document
>> help elmat Elementary matrices and matrix manipulation. Elementary matrices. zeros - Zeros array. ones - Ones array. eye - Identity matrix. repmat - Replicate and tile array. linspace - Linearly spaced vector. logspace - Logarithmically spaced vector. etc. For more information on elementary matrices see:
7. Operators and Expressions operation element-wise matrix-wise addition + + subtraction -- multiplication .* * division ./ / left division .\ \ exponentiation .^ ^ transpose w/o complex conjugation . ' transpose with complex conjugation ' >> help / >> help precedence

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

View Full Document
>> a = [1 2 5]; >> b = [4 -5 1]; >> a+b ans = 5 -3 6 >> a.*b ans = 4 -10 5 >> a./b ans = 0.2500 -0.4000 5.0000 >> a.\b ans = 4.0000 -2.5000 0.2000 % note: (a./b).*(a.\b) = [1,1,1]
>> a = [2 3 4 5]; >> a.^2 % [2^2, 3^2, 4^2, 5^2] ans = 4 9 16 25 >> 2.^a % [2^2, 2^3, 2^4, 2^5] ans = 4 8 16 32 >> a+10 ans = 12 13 14 15

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

View Full Document
>> A = [1 2; 3 4] A = 1 2 3 4 >> [A, A.^2; A^2, A*A] % form sub-blocks ans = 1 2 1 4 3 4 9 16 7 10 7 10 % note A^2 = A*A 15 22 15 22 >> B = 10.^A; >> [B, log10(B)] ans = 10 100 1 2 1000 10000 3 4
8. Functions >> help elfun % elementary functions list Some typical built-in elementary functions are: sin(x), cos(x), tan(x), cot(x) asin(x), acos(x), atan(x), acot(x) sinh(x), cosh(x), tanh(x), coth(x) asinh(x), acosh(x), atanh(x), acoth(x) exp(x), log(x), log10(x), log2(x) fix(x), floor(x), ceil(x), round(x) sqrt(x), sign(x), abs(x) sum(x), prod(x), cumsum(x), cumprod(x)

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.

## This note was uploaded on 10/25/2011 for the course COMPUTER S 101 taught by Professor Orfandi during the Spring '11 term at Rutgers.

### Page1 / 61

Week02 - Rutgers University School of Engineering Fall 2011 14:440:127 Introduction to Computers for Engineers Sophocles J Orfanidis ECE Department

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

View Full Document
Ask a homework question - tutors are online