flowchart+posted - TransferofControl

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

View Full Document Right Arrow Icon
Transfer of Control if if/else if/elseif/else switch/case end Relational operators, Logical operators, Conditionals 
Background image of page 1

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

View Full DocumentRight Arrow Icon
branching  IF  statement if  condition       action end
Background image of page 2
RELATIONAL OPERATORS Less than = Less than or equal Greater than = Greater than or equal = Equal = Not equal
Background image of page 3

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

View Full DocumentRight Arrow Icon
X and Y are  scalars   X < Y 1 true 0 false logical  varibles
Background image of page 4
Example:  Calculate y=sin(x)/x But what if x = 0 ? if x ~= 0 y = sin(x)/x; end
Background image of page 5

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

View Full DocumentRight Arrow Icon
LOGICAL OPERATORS Not ~ (5>6) (3==3)  (2<1) Or And (3==3)  |   (2<1)
Background image of page 6
X and Y are  arrays   X > Y [ 1 1 0 . .. 1 0 ] logical  array
Background image of page 7

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

View Full DocumentRight Arrow Icon
LOGICAL FUNCTIONS any (x) all (x) find (x) any ( any (A) ) find (x <= 1)
Background image of page 8
>> x = [ 1 0 1 0 1 0 0 0 1 1 0 0 ]; >> any(x) ans = 1 1 1 0 >> any(any(x)) ans = 1 >> all(x) ans = 1 0 0 0 >> all(all(x)) ans = 0
Background image of page 9

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

View Full DocumentRight Arrow Icon
>> x = [ 1 0 1 0 1 0 0 0 1 1 0 0 ]; >> find(x) ans = 1 2 3 6 7 >> [i,j] = find(x) i = 1 2 3 3 1 j = 1 1 1 2 3
Background image of page 10
>> x = [ -1 2 8 9 -3 7 0 1 5 4 6 -2 ]; >> find(x > 1) ans = 2 4 5 8 9 10 11
Background image of page 11

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

View Full DocumentRight Arrow Icon
branching  IF-ELSE  statement if  condition1       action1 else       action2 end
Background image of page 12
Example:  Calculate y=sin(x)/x if x ~= 0 y = sin(x)/x; else y = 1; end
Background image of page 13

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

View Full DocumentRight Arrow Icon
Example:  Calculate y=sin(x)/x if x > 1e-5 y = sin(x)/x; else y = 1-x^2/6; end
Background image of page 14
branching  IF - ELSEIF - ELSE if       condition1       action1 elseif  condition2       action2 else       action3 end
Background image of page 15

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

View Full DocumentRight Arrow Icon
MULTIPLE SELECTION switch   expression    case  test_value1         commands1    case  test_value2         commands2    otherwise         commands3 end
Background image of page 16
MATLAB IMPLEMENTATION gradeA = 0; gradeB = 0; gradeC = 0; gradeD = 0; gradeF = 0;
Background image of page 17

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

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

This note was uploaded on 08/14/2010 for the course E 7 taught by Professor Patzek during the Summer '08 term at University of California, Berkeley.

Page1 / 32

flowchart+posted - TransferofControl

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

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