# Lecture32 - Lecture 32 Programming in MATLAB Engineering...

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

Engineering 101 Engineering 101 Lecture 32 Lecture 32 Programming in MATLAB Programming in MATLAB Prof. Michael Falk University of Michigan, College of Engineering

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

View Full Document
Announcements Announcements Project 7 – Due Today at 5pm Turned in on paper in Pierpont B519 May be turned in early to your GSI or to their mailbox in Pierpont B519 (this room is not open all hours, but Chad will be around there or B505/507 from 2:30-5).
Array vs. Matrix operations Array vs. Matrix operations When two arrays are being operated on MATLAB makes a distinction between array an matrix operations. Matrix operations are the standard Linear Algebra operations Array operations are done on an element-by-element basis

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

View Full Document
Array vs. Matrix operations Array vs. Matrix operations Array or Matrix operations (no difference) Addition a + b Subtraction a – b Array (Element-by-element) operations Multiplication a .* b Right Division a ./ b Left Division a .\ b Exponentiation a .^ b
Array vs. Matrix operations Array vs. Matrix operations Matrix operations Multiplication a * b Right Division a / b Left Division b \ a Multiplication does standard matrix multiplication. The columns of a must equal the rows of b. Division inverts the denominator matrix and multiplies by the numerator.

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

View Full Document
Matrix Operation Examples Matrix Operation Examples a = [ 1 2; 5 –1 ] b = [ 0 1; 1 2 ] a + b a – b a * b a .* b
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b a * b a .* b

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

View Full Document
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 1 3 a * b 6 1 a .* b
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 1 1 a * b 4 -3 a .* b

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

View Full Document
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 2 5 a * b -1 3 a .* b
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 2 5 a * b -1 3 a .* b

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

View Full Document
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 2 5 a * b -1 3 a .* b
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 2 5 a * b -1 3 a .* b

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

View Full Document
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b 0 2 a * b 5 -2 a .* b
C++ function and corresponding MATLAB C++ function and corresponding MATLAB function function void process (vector <double> list, for(int x=0; x<list.size(); x++){ h[x] = list[x]*3.0; if (x==0 or g < h[x]) g= h[x]; } } function [g, h] = process( list ) h = 3 * list; g = max(h);

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

View Full Document
Exercise 1 Exercise 1 Convert from MATLAB function to C++ procedure function [x, y] = splitstring(a) s = floor(length(a)/2) ; x = a(1 :s) ; y = a(s+1:length(a));
Exercise 1 Exercise 1 Convert from MATLAB function to C++ procedure function [x, y] = splitstring(a) s = floor(length(a)/2) ; x = a(1 :s) ; y = a(s+1:length(a)); int s = a.size()/2 ; x = a.substr(0, s) ; y = a.substr(s, a.size()-s) ; return; } 4

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

View Full Document
MATLAB Functions MATLAB Functions There are a large number of predefined mathematical functions in MATLAB.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/02/2008 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.

### Page1 / 63

Lecture32 - Lecture 32 Programming in MATLAB Engineering...

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

View Full Document
Ask a homework question - tutors are online