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.

Companion M-Files Feature 2 To label many curves on aplot it is better to put the text close to the curves themselves ratherthan in a separate legend <strong>of</strong>f to one side. Legends force the eyeto make many jumps between the plot <strong>and</strong> the legend to sort outwhich line is which. Although matlab comes equipped with alegend function, I prefer to use the companion m-file curlabel,which is good especially for labelling plots which are close together:t = 0:.1:2*pi;plot(t,sin(t),t,sin(1.05*t))curlabel(’frequency = 1’)curlabel(’frequency = 1.05’)axis([0 max(t) -1 1])zeroaxesYou must use the mouse to specify the start <strong>and</strong> end points <strong>of</strong> thepointer lines. The echo from the function can be pasted into anm-file for future use.5 More Matrix AlgebraYou can multiply two matrices together using the * operator:>> a = [1 2;3 4]a =1 23 4>> b = [1 0 1 0;0 1 1 0]b =1 0 1 00 1 1 0>> a*bans =1 2 3 03 4 7 0>> u = [1 2 0 1]u =1 2 0 1>> v = [1 1 2 2]’c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!