X 0 05pi pi 15pi 20pi y sinx y 0 1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sin(x); % y == [ 0 1 0 1 0 ] 5 Outline Lecture 15 and 16 Intro to MATLAB and Matrices Lecture 17 Script and Function Files Lecture 18 and 19 MATLAB Programming Lecture 20 Subarrays and Vectorization Lecture 21 Plotting in MATLAB Conditional Operators in MATLAB == ~= > >= < <= equal to not equal to greater than greater than or equal to less than less than or equal to These return 1 for true or 0 for false Conditional Operators Conditional operators can be used between arrays 1 5 > 3 1 0 1 3 -1 -1 2 1 0 They can also be used between a scalar and an array 5 > 8 2 0 1 10 -1 0 1 Logical Operators in MATLAB & | xor( ) ~ A 0 0 1 1 B 0 1 0 1 A&B 0 0 0 1 Logical AND Logical OR Logical Exclusive OR Logical NOT A|B 0 1 1 1 xor(A, B) 0 1 1 0 The If Construct in MATLAB The basic form of the if construct in MATLAB is: if control_exp1 statement1 statement2 etc. elseif control_exp2 statement 3 statement 4 etc. else statement 5 statement 6 end The Switch Construct MATLAB also has a switch construct for cases in which you are choosing from a number of alternatives: switch (switch_expr) case case_expr_1 Statement 1 Statement 2 case case_expr_2 Statement 3 Statement 4 otherwise Statement 5 end Every construct must have an if and an end. The other parts are option...
View Full Document

This note was uploaded on 05/04/2010 for the course ENGIN 101 taught by Professor Jeffringenberg during the Spring '07 term at University of Michigan.

Ask a homework question - tutors are online