12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

39 Answers to Exercises(Part I, <strong>Basics</strong> <strong>of</strong> <strong>MATLAB</strong>)Exercise 1 (Page 9)The first three columns are a copy <strong>of</strong> the a matrix. The second threecolumns are the elements <strong>of</strong> a indexed by the elements <strong>of</strong> a. For example,a(a(3,2)) = a(8) = 6, which yields the marked element >6< <strong>of</strong> theanswer:3>> [a a(a)]ans =1 2 3 1 4 74 5 6 2 5 87 8 9 >6< 9Exercise 2 (Page 39)function out = posneg(in)% Test for all positive (1), or all negative (-1) elements.if all(in>0)out = 1;elseif all(in

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

Saved successfully!

Ooh no, something went wrong!