Lecture32 - Lecture 32 Programming in MATLAB Engineering...

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

View Full Document Right Arrow Icon
Engineering 101 Engineering 101 Lecture 32 Lecture 32 Programming in MATLAB Programming in MATLAB Prof. Michael Falk University of Michigan, College of Engineering
Background image of page 1

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

View Full DocumentRight Arrow Icon
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).
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Matrix Operation Examples Matrix Operation Examples a = [ 1 2; 5 –1 ] b = [ 0 1; 1 2 ] a + b a – b a * b a .* b
Background image of page 6
Matrix Operation Examples Matrix Operation Examples a = 1 2 b = 0 1 5 -1 1 2 a + b a – b a * b a .* b
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
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
Background image of page 13

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

View Full DocumentRight Arrow Icon
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
Background image of page 14
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);
Background image of page 15

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

View Full DocumentRight Arrow Icon
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));
Background image of page 16
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
Background image of page 17

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

View Full DocumentRight Arrow Icon
MATLAB Functions MATLAB Functions There are a large number of predefined mathematical functions in MATLAB.
Background image of page 18
Image of page 19
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 Right Arrow Icon
Ask a homework question - tutors are online