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.

max returns a vector containing the maximum value <strong>of</strong> each column.When given a vector, max returns the maximum value:>> max(m)ans =9To find the index corresponding to the maximum value, supply two outputarguments to max:>> [v,ind] = max(m)v =9ind =2The first argument is the maximum value <strong>and</strong> the second is the index <strong>of</strong>the maximum value. Another example is>> x = 0:.01:2;>> y = humps(x);>> plot(x,y)>> [v,ind] = max(y)v =96.5000ind =31>> hold on>> plot(x(ind),y(ind),’ro’)>> x(ind)ans =0.3000>> y(ind)ans =96.5000The find function is <strong>of</strong>ten used with relational <strong>and</strong> logical operators:Relational operators == equal to~= not equal to< less than> greater than= greater than or equal toc○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!