13.01.2015 Views

Chapter 4: Programming with MATLAB - FET

Chapter 4: Programming with MATLAB - FET

Chapter 4: Programming with MATLAB - FET

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4-15<br />

Logical Operators & and the find Function<br />

>>x = [5, -3, 0, 0, 8]; y = [2, 4, 0, 5, 7];<br />

>>z = find(x&y)<br />

z =<br />

1 2 5<br />

Note that the find function returns the indices, and not the<br />

values.<br />

In the following session, note the difference between the<br />

result obtained by y(x&y) and the result obtained by<br />

find(x&y) in the previous example.<br />

>>values = y(x&y)<br />

values =<br />

2 4 7<br />

>>how_many = length(values)<br />

how_many =<br />

3<br />

Z.R.K

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!