lecturenotes10_15 - Logical Arrays Wednesday October 15,...

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

View Full Document Right Arrow Icon
Logical Arrays Wednesday October 15, 2008
Background image of page 1

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

View Full DocumentRight Arrow Icon
Logical Arrays Logical arrays are arrays of “1”s and “0”s, which represent “true” and “false”, respectively Logical arrays are the result of application of a logical operation on an array of values (or potentially another logical array)
Background image of page 2
Example 1 = 9 8 7 6 5 4 3 2 1 a = = b a b 5 Note that b is NOT the same as a numerical array of ones and zeros. This is the most common form of a logical array!
Background image of page 3

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

View Full DocumentRight Arrow Icon
Checking the data type “whos” shows a list of the variables and types: >> whos “isnumeric” also returns a value of “false” when applied to b (but is “true” when applied to a )
Background image of page 4
if/else masking We can use the logical array to perform ”if/ else” operations in the faster array arithmetic form of matlab Example: Suppose we now wanted to calculate c , where c is an array containing the square root of a , for only those values where a>5 .
Background image of page 5

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

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

This note was uploaded on 02/25/2009 for the course BEE 1510 taught by Professor Staff during the Fall '05 term at Cornell University (Engineering School).

Page1 / 12

lecturenotes10_15 - Logical Arrays Wednesday October 15,...

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

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