<MakerFile 4.0K> Aa•ÿ a € d H H d ½ TableFootnote ] Ç $ * à # d 6 6 Footnote . * à _ Ç 6 6 . ÌÌ ÌÌ ÌÌ / - Ð Ñ :;,.É!? TOC Heading ff @ + logon u l =Ò e ž =Ú k " EquationVariables =Ó f ¢ =Ô g ¤ @u m ª =Õ h ! =× i ! @À e =Ø j " u … w u ! þ v " ý ý <$lastpagenum> þ <$monthname> <$daynum>, <$year> ÿ "<$monthnum>/<$daynum>/<$shortyear> ;<$monthname> <$daynum>, <$year> <$hour>:<$minute00> <$ampm>; "<$monthnum>/<$daynum>/<$shortyear>V9 <$monthname> <$daynum>, <$year>? "<$monthnum>/<$daynum>/<$shortyear>WÏ <$fullfilename> <$filename>€ <$paratext[Title]> <$paratext[Heading]> <$curpagenum> <$marker1> <$marker2> (Continued) Heading & Page Ò<$paratext>Ó on page <$pagenum> Page page <$pagenum>t on page <$pagenum>. See Heading & Page %See Ò<$paratext>Ó Table & Page 7Table <$paranumonly>, Ò<$paratext>,Ó on page <$pagenum> + (Sheet <$tblsheetnum> of <$tblsheetcount>) • • • l • | | Q A l Ž } } Q A l • ~ ~ P =Ò ž l • • • P =Õ ! l ‘ € € P =Ú " l ’ • • P w ! l “ ƒ ™ Q ý A l ” ñ ‘ = ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ ¨ ¨ ø = = G A B A = M = = = = < < = < < S thn A> =Û n $ > e i ; n $ > e o m Ï =Ü =Ý =Þ =ß =à =á =â =ã =ä =å =æ =ç =è =é =ê =ë =ì =í S =î T = = = = = i u =ï =ð =ñ =ò =ó = =ô = r =õ = o =ö Q e =÷ = < =ø R p = Q = Q = = Q Q Q Q J = = = = - = N e = = Q Q Q Q r 7 o x p + e s | =ù =ú =û =ü @j @k @H @I @J @K > > > > > > > > = > ! = > " = > # R > $ % & ' ( ) * + , . / 0 1 2 3 4 5 6 7 8 9 : ; < > ? @ A B C D E F G H I J K L M N O P Q R S T U V = N = P = = € O " T T T = = L = ‘ = Q Q n = $ = = > N e = i = ; O n : $ : : > N e = o O m O Ï : = >. = >/ : T a = i = u = >4 = = r = o = e R < = p = J e J N = r : : > > > > > > > > > > > > > @L > >> > >! >" ># >$ >% >& >( >) >* >+ >, >- >0 >1 >2 >3 >5 >6 >7 >8 >9 >: >; >< >= >> >? >@ >A W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ • € • ‚ ƒ = N O : : N = = = O P P = = N = = = J E E = R = = = J J Q Q J J = R = = = = J Q Q Q J Q Q 7 o x p + e s | P € " ‘ n $ > e i ; n $ > e o m Ï >B >C >D >E >F >G >H >I >J >K >L >M >N >O >P >Q >R >S >T >U >V >W >X >Y >Z >[ >\ >] >^ >_ >` >a >b >c >d >e >f >g >h >i >j >k >l >m >n „ Q … † ‡ ˆ ‰ Q N : : : >o T i u >t >p >q >r >s Š ‹ Œ • Ž • • ‘ ’ “ ” • – — ˜ ™ š › œ • ž Ÿ ¡ ¢ £ ¦ ¹ » ¼ ½ ¾ ¿ À Á Â Ã Æ È Ê Ë Ì Í Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü = = = = = = = J Q Q Q Q J Q a a a J Q ^ ^ ^ ^ ^ J V Q R < Q = = = = N W N = N W N N < O Q = N J Q Q Q Q Q Q r o e < p e r 7 o x p + e s | Q < Q P = = € = " = N = W ‘ N N n $ > e i ; n $ > e o >u >v >w >x >y >z >{ >| >} >~ >• >€ >• >‚ >ƒ >„ >… >† >‡ >ˆ >‰ >Š >‹ >Œ >• @M >£ @% @N @P @T @U @Y @_ @` @a @n @x @r @s @y @z >¥ >¦ >§ >¨ >© >ª >« >¬ >>® >¯ >° Ý Þ ß à Q Q Q Q m Ï >± >² >³ >´ á ; â ã ä å æ ; ; ; ; O ç è é ê ë ì í î ï ð ò ó ô ö ÷ ø ù ú û ü ý þ ÿ N Q Q Q K K K K K Q R = = = J Q [ J Q [ J = R >µ T i u >¶ >· >¸ >¹ >º r o e < p e r 7 o x p + e s | >» >¼ >½ >¾ >¿ >À >Á > >à >Å >Æ >Ç >É >Ê >Ë >Ì >Í >Î >Ï >Ð >Ñ >Ò >Ó = >Ô = >Õ Q >Ö Q >× = >Ø = >Ù = P >Ú Q >Û Q € >Ü Q " >Ý Q >Þ J >ß Q >à Q >á J >â Q >ã Q ‘ >ä = >å = n >æ J $ >ç Q >è Q > >é J e >ê R i >ë = ; >ì = n >í = $ >î ! = >ï " J > >ð # Q e >ñ $ Q o >ò % Q m >ó & Q Ï >ô ' J >õ ( C >ö ) C >÷ * C T >ø + C >ù , C i >ú - C u >û . C >ü / C >ý 0 C r >þ 1 = o >ÿ 2 R e ? 3 = < ? 4 = p ? 5 = ? 8 = e ? 9 J ? : Q ? ; Q r ? < Q ? = Q ? > Q 7 ? ? Q o ? @ Q x ? A Q p ? B Q + ? C Q e ? D Q s ? E Q ? F Q ? G Q | ? H Q ? I O ? J O ? K O ? L O ? M O ? N O P ? O O ? P O € ? Q O " ? R O ?- S N ? T O ? U O ?! V O ?" W O ?# X O ‘ ?$ Y O ?% Z O n ?& [ O $ ?' \ O ?( ] O > ?) ^ O e ?* _ O i ?+ ` O ; ?, a O n ?- b O $ ?. c O ?/ d O > ?0 e O e ?1 f O o ?2 g O m ?3 h O Ï ?4 i O ?5 j O ?6 k O ?7 l Q T ?: o N ?; p = i ?< q O u ?= r O ?> s O ?? t O r ?@ u O o ?A v O e ?B w O < ?C x O p ?D y O ?E z O e ?F { O ?G | O ?H } O r ?I ~ O ?J • O ?K € O 7 ?L • O o ?M ‚ O x ?N ƒ O p ?O „ O + ?P … O e ?Q † O s ?R ‡ N ?S ˆ Q ?T ‰ Q | ?U Š Q ?V ‹ Q ?W Œ Q ?X • Q ?Y Ž Q ?Z • N ?[ • J P ?\ ‘ Q ?] ’ Q € ?^ “ Q " ?_ ” Q ?` • Q ?a – Q ?b — N ?c ˜ J ?d ™ Q ?e š Q ‘ ?f › Q ?g œ Q n ?h • Q $ ?i ž N ?j Ÿ Q > ?k Q e ?l ¡ Q i ?m ¢ Q ; ?n £ Q n ?o ¤ Q $ ?p Ý = ?q ß R > ?r à < e ?s á = o ?t â = m ?u ã = Ï ?v ä = ?w å = ?x æ = ?y ç R T ?z è J ?{ é J i ?| ê Q u ?} ë J ?~ ì Q ?• í Q r ?€ î J o ?• ï J e ?‚ ð Q < ?ƒ ñ Q p ?„ ò J ?… ó J e ?† ô Q ?‡ õ Q ?ˆ ö J r ?‰ ÷ J ?Š ø Q ?‹ ù Q = 7 o ?Œ ?• = x ?Ž = p ?• = + = = = R = N N N = = = = = = = - < = = # = % N & N ' N ( N * = + = , = - = . = / = 0 = 1 < 4 = 5 = 7 = 8 D = = > H ? = @ = A = e s | P € " ‘ n $ > e i ; n $ > e o m Ï ?• ?‘ ?’ ?“ ?” ?• ?– ?— ?˜ ?™ ?š ?› ?œ ?• ?ž ?Ÿ ? ?¡ ?¤ ?¦ ?§ ?¨ ?© ?« ?¬ ??® ?¯ ?° ?± ?² ?´ ?µ ?¶ ?· ?¸ ?¹ ?º ?» ?¼ ?½ B H C D E F M I I = = N N O P Q N N N N ?¾ T i u ?¿ ?À ?Á ? ?à r o e ?Ä ?Å ?Æ ?Ç R S T U V W X ` c d f g h o q r u w | } ~ • € ‚ ƒ „ … † N N J Q Q Q Q = Q J ^ N : J Q Q Q Q Q Q Q C C N N Q Q Q < p e r 7 o x p + e s | P € ?È ?É ?Ê ?Ë ?Ì ?Í ?Î ?Ï ?Ð ?Ñ ?Ò ?Ó ?Ô ?Õ ?Ö ?× ?Ø ?Ù ?Ú ?Û ?Ü ?Ý ?Þ ?ß ?à ?á ?â m - › ; d ?ä m Ñ ¡ • | d ?å n Ñ ‘ ?« • } = d ?æ o Ñ ® p { e H “Ó 3Kº ^¨ ?ç p Ò q o n H “Ó 3Kº ^¨ H R H R ¡ Footnote > H ^¨ ?è q Ò p r o H H qùv ?ü^¨ H z·¸ H z·¸ ¡ Single Line H ' ´ ?é r Ó q t o qùv ?ü- I s s • • ^¨ ?ë t Õ r u o H §ùv D£f ^¨ H °·¸ H °·¸ ¡ Double Line H º Footnote u ?ê s × r o Ô N ™ H §ùv D£f ?ì u Ó t x o v w Double Line ?Ò Ô Q Ô ~ Q ?ï x Ó u z o ?Ñ ?í v Ö Ô Ô H † w u ?î w Ö v Ô Ô u ?Ö Ú Ô N Single Line y y Ô ?ð y Ö x Ô ¡ Ô H Z ´ ?ñ z Ó x { o TableFootnote= ^¨ ?ò { Ó ® E¸¾ GX- RŸb ^¨ E¸¾ P o E¸¾ TableFootnoteç } E¸¾ GX- RŸb z o P o ¡ 6 6 ø ¬ ?ó | Ó € m 6 • ñ ™ H 6 6 ø ¬ ?è 6 ø ¬ ` ?ô } Ó ~ n 6 Ž 6 ø ¬ I ò ™ 6 ` ø ?õ ~ Ó • } n 6 • ó ›^¨ o 6 ø ªª Page ø ?ö • Ó j 1 k ~ n ªª UU h 6 • ô › w 6 ø x öUV ø ?÷ € Ó • | m ªª ªª UU ` 6 ‘ õ › 6 öUV ø ?Ö ø ?ø • Ó € m ªª ªª UU ` 6 ø ’ ö › z ªª d ªª ?ù ‚ Ñ UU ` n ƒ § ?ð 6 6 ø ¬ ?ú ƒ Ó œ ‚ ¡ 6 “ ÷ ™ 6 ø ¬ … 0 { ` ` á ™eF n $ ` â ™^¨ 2 ` ã ™ ® @ ™¸¾ o N ™eF n \ ™ j ™ x ™ † ™ è ” ™ H ª ø • 6 ¼ ù ™ Ê ú ™ ` ` ` ` ` ` ` ` Introduction to Matlab ` ` I Ø ü ™ ` æ û ™?õ Ó ô ` ` å ™ ` æ ™ ` ª # 1 * + , . ô ™ªª ™ , ™ : ™ H ™ V ™ d ™ r / ™ € 0 ™ Ž ` ` ` ` ` ` ` ` ` ™ œ ` ™ Ö ª h ý ™ h July 19, 1995 i ¸ ` þ ™ Thomas D. Citriniti Æ ` ™ Information Technology Services Ô ` » ™?ù !Rensselaer Polytechnic Institute â ` ™ Troy, New York 12180 ð ` ™ þ ` ™ ` ™ ` ™ ( ` ™ 6 ` ™ D ` ™ R ™ bThis tutorial was written to introduce MATLAB and provide examples to use in conjunction with the ` ™ kPreface program. It assumes the user has sufficient familiarity with the operating system to logon, create n @ ™ files, and change directories. | ` ÿ ™ Š ` ™ ˜ ` ™ ¦ ` ä ™ d ?û „ Ñ … … 6 6 ø ¬ ?ü … Ó „ 6 “ 5 ™ UT 6 ø ¬ ƒ ‡ 0 UT ªª ` ` Ö 1.1 Accessing MATLAB %ÿþ ` ™ 3ÿþ ™Th gOnce a login session has been established select Matlab from the RCS Applications menu. This will open aer Aÿþ ™tu `a command window in which we will send Matlab commands. Note a change in prompt (from % to >>). Oÿþ @ ™ GOn line help is available for most MATLAB commands. To invoke it type: D ]ÿþ ` ™ kÿþ ` ™Th ¨ >> help yÿþ ` ™ce T ‡ÿþ ` ™am 8which provides a list of help topics to choose from, or Pr •ÿþ ` - ™as e £ÿþ ` ¨ >> help topic wi ±ÿþ ` ™ys ¿ÿþ ` ! ™ Jwhich invokes a help file for the topic specified. Try ¨ help plot ™ . Íÿþ ` " ™ ÝUR # - UT ªª ` 2.1 Entering Matrices ëÿü ` ™ ùÿü ™ gMatrices can be entered into matlab from the command line or thorough data files, we will be doing all ƒ ‡ ÿü @ ™ dour work from the command line. Here is how to create a 3x3 matrix and assign it to the variable A. ÿü ` $ ™og s #ÿü ` % ¨ta >> A = [ 1 2 3; 4 5 6; 7 8 9 ] A 1ÿü ` & ™Th w ?ÿü ` ' ™ 2This produces the following response from MATLAB: Mÿü ` ( ™No a [ÿü ` ) ¬(f A = iÿü ` * ¬ 1 2 3 GOn wÿü ` + ¬la 4 5 6 ost …ÿü ` , ¬To 7 8 9 t t “ÿü ` - ™ ¡ÿü ` . ™ \Note that MATLAB is case sensitive. Thus, when using variables, ÒAÓ is not the same as ÒaÓ. h ¯ÿü ` 0 ™se o ½ÿü 1 ™ ^Random numbers and matrices. RAND(N) is an N-by-N matrix with random entries. RAND(M,N) is an Ëÿü 1 ™he bM-by-N matrix with random entries. RAND(A) is the same size as A. RAND with no arguments is a sca Ùÿü @ 1 ™ri 4lar whose value changes each time it is referenced. ic çÿü ` 5 ™in m õÿü ` 6 ¨ma >> A = rand(3,2) ÿü ` 7 ™l d ÿü ` 8 ™ ¬ A = ÿü ` 9 ¬e m -ÿü ` : ¬ho 0.2342 0.3243 ma ;ÿü ` ; ¬ t 0.1334 0.1212 Iÿü ` < ¬og 0.8656 0.4543 ¨ta Wÿü ` > ¨ 4 >> A(3,2) ¤ A eÿü ` ? ™Th w sÿü ` @ ¬ ans = •ÿü ` A ¬in e •ÿü ` B ¬: 0.4543 •ÿü ` C ™ d ?ý † Ñ 3 ‡ ‡ la 4 $ 6 7 ¬ ?þ ‡ Ó † ü $ 6 7 ¬ … ‰ “ 0 t D ™ s wOnce a matrix has been assigned to variable A, it is stored for theduration of the MATLAB session, or until you assign num @ D ™ 7new values to A. To clear A of any value, use clear A: is $ ` G ™ 1 e 2 ` H ™th >> clear A s. @ ` I ™me z N ` J ™no &To empty all variables at once, type: \ ` K ™ch e j ` L ™re >> clear x ` M ™in m ‡UT UT ªª ` N -ma 3.1 Matrix operations •ÿþ ` O ™ d ü £ÿþ P ™ rWhile matrix operations act upon an entire matrix, MATLABÕs array operators act upon the individual elements of a ±ÿþ @ P ™ 0 /matrix. For example, using A and B defined as: ,2) ¿ÿþ ` 3 ™ ? h Íÿþ ` 4 ™ @ Ûÿþ ` S ¨ >> A = [ 1 2; 3 4 ] éÿþ ` T ™ ¬ A = ÷ÿþ ` U ¬ 1 2 ÿþ ` V ¬ 3 4 3 ÿþ ` W ™ !ÿþ ` X ¨ >> B = [ 5 6; 7 8 ] /ÿþ ` Y ¬ B = =ÿþ ` Z ¬ 5 6 Kÿþ ` [ ¬On 7 8 t Yÿþ ` \ ¨ne >> C = A * B gÿþ ` ] ™th r uÿþ ` ^ ™B )produces the Matrix operation result of: ƒÿþ ` _ ™es ‘ÿþ ` ` ¬ny C = Ÿÿþ ` a ¬ F 19 22 or A(1,1)*B(1,1)+A(1,2)*B(2,1) A(1,1)*B(1,2)+A(1,2)*B(2,2) -ÿþ ` b ¬ G 43 50 or A(2,1)*B(1,1)+A(2,2)*B(2,1) A(2,1)*B(1,2)+A(2,2)*B(2,2) j »ÿþ ` c ™ > where Éÿþ ` d ™in m ×ÿþ ` e ¨ma >> C = A .* B ati åÿþ ` f ™ O d óÿþ ` g ™ P (produces the Array operation result of: en ÿþ ` h ™BÕ r ÿþ ` i ©up ¬ C = v ÿþ ` j ¬a ' 5 12 or A(1,1)*B(1,1) A(1,2)*B(1,2) , u +ÿþ ` k ¬ed ( 21 32 or A(2,1)*B(2,1) A(2,2)*B(2,2) 9ÿþ ` l ™ Gÿþ ` ™[ ; WUR UT ªª ` m ,4.1 Statements, expressions, and variables. eÿü ` n ™ 3 sÿü ` o ™ W NThe semicolon (;) following a statement will suppress printing of the result. •ÿü ` p ™ 5 •ÿü ` q © [ >> A = [ 1 2; 3 4 ] •ÿü r ©A ` d ?ÿ ˆ Ñ ‰ ‰ op at 6 6 ø ¬ @ ‰ Ó ˆ 6 “ ©(1 6 ø ¬ 0 1 ¬ A = ` ‡ ‹ ` B s ¬2) 1 2 * $ ` t ¬ 3 4 2 ` ¤,1 ( @ ` u © >> A = [ 1 2; 3 4 ]; N ` v © >> > \ ` w ™ d kUT UT ªª ` x 5.1 Matrix Building Functions. yÿþ ` y ™ÿþ ‡ÿþ ` z ™uc KAll zeros. ZEROS(N) is an N-by-N matrix of zeros. ZEROS(M,N) is an M-by-N ©up •ÿþ ` { ™ ?matrix of zeros. ZEROS(A) is the same size as A and all zeros. £ÿþ ` | ™r , ±ÿþ ` } ©(2 >> A = zeros(2,3) ` l ¿ÿþ ` ~ ¬ A = Íÿþ ` • ¬ m 0 0 0 St Ûÿþ ` € ¬on 0 0 0 ria éÿþ ` • © >> A = zeros(3) ÷ÿþ ` ‚ ¬se A= n ÿþ ` ƒ ¬at 0 0 0 l s ÿþ ` „ ¬f 0 0 0 t. !ÿþ ` … ¬ 0 0 0 /ÿþ ` † ¨A >> A = rand(3) ÿü =ÿþ ` g © Kÿþ ` ‡ ¬?ÿ A= Yÿþ ` E ¬ 0.3245 0.6457 0.7324 gÿþ ` ˆ ¬ Ó 0.4734 0.2333 0.2168 ø uÿþ ` ‰ ¬ 0.1205 0.3913 0.9573 ƒÿþ ` h ¤ B ‘ÿþ ` Š ™ 1 * Ÿÿþ ` ‹ ™ PIf V is a row or column vector with N components, DIAG(V,K) is a square matrix -ÿþ ` Œ ™ > Mof order N+ABS(K) with the elements of V on the K-th diagonal. K = 0 is the »ÿþ ` • ™ÿþ Mmain diagonal, K > 0 is above the main diagonal and K < 0 is below the main O Éÿþ ` Ž ™N Odiagonal. DIAG(V) simply puts V on the main diagonal. (note: Your results will ze ×ÿþ ` • ™ Cdiffer since the rand function returns an array of randum results) ` ~ åÿþ ` • ™ óÿþ ` ‘ ©St >> X = diag(A) on ÿþ ` R © ÿþ ` ’ ¬ze X = ÿþ ` “ ¬se 0.3245 ÿþ +ÿþ ` ” ¬ 0 0.2333 ÿþ 9ÿþ ` • ¬ 0 0.9573 ÿþ Gÿþ ` c ¤ 0 0 Uÿþ ` – © † >> X = diag(diag(A)) cÿþ ` Q © qÿþ — ¬?ÿ ` X = •ÿþ ˜ ¬ ` 0.3245 0 0 57 •ÿþ ™ ¬ ` 0 0.2333 0 0 ›ÿþ š ¬68 ` 0 0 0.9573 d @ Š Ñ ‹ ‹ 6 6 ø ¬ @ ‹ Ó Š 6 6 “ F ¤ix ø ¬ ‰ • 0,K ` ` © > - >> B = [ A, zeros(3,2);zeros(2,3), eye(2) ] $ ` © = 2 ` ¬ B = @ ` ¬ > 0.3245 0.6457 0.7324 0 0 an N ` ž ¬he 0.4734 0.2333 0.2168 0 0 Odi \ ` Ÿ ¬mp 0.1205 0.3913 0.9573 0 0 l. j ` ¬s 0 0 0 1.0000 0 x ` ¡ ¬in 0 0 0 0 1.0000 n † ` f ¤of n ” ` ¢ ©ÿþ › h d i œ þ • ¬ >> © ¢ ` o © ‘ t ° / ™on gTRIU(X) is the upper triangular part of X. TRIU(X,K) is the elements on and above the K-th diagonal of 0 ¾ @ / ™ fX. K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0 is below the main diagonal. Ì ` Ô ™ — Ú ` Õ ¨ >> a = rand(5),b = triu(a) þ è ` Ö © 2 ö ` × ¬ a = 8 ` Ø ¬ ` Ù ¬ Ñ $ 0.9103 0.3282 0.2470 0.0727 0.7665 ` Ú ¬ $ 0.7622 0.6326 0.9826 0.6316 0.4777 . ` Û ¬ $ 0.2625 0.7564 0.7227 0.8847 0.2378 < ` Ü ¬ > $ 0.0475 0.9910 0.7534 0.2727 0.2749 ey J ` Ý ¬ $ 0.7361 0.3653 0.6515 0.4364 0.3593 þ X ` Þ ¬ > 0 f ` ß ¬4 b = n t ` à ¬he 0 ‚ ` á ¬8 ( 0.9103 0.3282 0.2470 0.0727 0.7665 13 • ` â ¬ # 0 0.6326 0.9826 0.6316 0.4777 x ž ` ã ¬ 0 - 0 0 0.7227 0.8847 0.2378 ¬ ` ä ¬ 0 0 0 0.2727 0.2749 º ` å ¬ t 0 0 0 0 0.3593 R È ` æ ¬ t n Ö ` ç ¨RI >> a == b el ä è ¬e ò é ¬ 0 ` ` ans = ` ê ¬ i h ` ë ¬ > 1 1 1 1 1 in ` ì ¬0 0 1 1 1 1 di * ` í ¬ 0 0 1 1 1 8 ` î ¬a 0 0 0 1 1 (a F ` ï ¬ Ö 0 0 0 0 1 T ` ð ¬ ¤ cUT UT ªª ` ò 6.1 Scalar functions. qÿþ ` ó ™ 0 6 •ÿþ ` ô ™ Ú iScalar functions are math functions that operate on a single value at a time throughout the whole array. •ÿþ ` ö ™ 0 7 ›ÿþ ` ÷ ©27 " >> a = [ 2*pi 3*pi/2 pi pi/2 0 ] d @ Œ Ñ • • 6 6 ø ¬ @ • Ó Œ 6 “ q ¬ 6 ø ¬ ‹ • 007 ` ` ø ¬32 a = 2 $ ` ù ¬ 6.2832 4.7124 3.1416 1.5708 0 227 2 ` r ¬ @ ` ú © 0 >> sin(a) .27 N ` u ¬ å t \ ` û ¬35 ans = j ` ü ¬ ! -0.0000 -1.0000 0.0000 1.0000 0 x ` w ¬ † ý © a ” þ ™ i h £UT ÿ - > ±ÿþ ` >> ` UT ªª ` 7.1 Vector functions. ` ™ 1 ¿ÿþ ™ lVector functions are math functions that operate on a vector, a vector is a single row array. MAX(X) is the Íÿþ ™ dlargest element in X. For matrices, MAX(X) is a vector containing the maximum element from each col ar Ûÿþ ™h dumn. [Y,I] = MAX(X) stores the indices of the maximum values in vector I. MAX(X,Y) returns a matrix 7 éÿþ @ ™27 Jthe same size as X and Y with the largest elements taken from X or Y. £ ÷ÿþ ` ‚ ¨ ÿþ ` ƒ ¨ >> a = [ 1 2 3; 4 5 6; 7 8 9 ] ÿþ ` Ò ¬ • !ÿþ ` ¬07 /ÿþ a = ` ¬ ` ø =ÿþ 1 2 3 ` ¬ ¬ 4 5 6 Kÿþ ` ¬.1 7 8 9 8 0 Yÿþ Ó ¬ r gÿþ ` ` š ú >> max(a) (a) uÿþ ` ¬ u å ƒÿþ ` ¬ û ans = s = ‘ÿþ ` ¬ ü 7 8 9 .00 Ÿÿþ ` ¬1. 0 -ÿþ ` š w >> max(max(a)) »ÿþ ` ¬ Éÿþ „ ¬UT ` ÿ ×ÿþ ` ans = ` ¬un s. åÿþ … ¤ 1 óÿþ 9 ` ™ gFor vectors, SUM(X) is the sum of the elements of X. For matrices, SUM(X) is a row vector with the sum th ÿþ @ ™ 2over each column. SUM(DIAG(X)) is the trace of X. ÿþ ` ™g ÿþ ` ©om +ÿþ š >> sum(a) ` ¬ [ ] 9ÿþ ` † ¬he ans = of Gÿþ ` ¬ i 12 15 18 Uÿþ ` © m i eUR UT ªª ` - 8.1 Matrix functions. sÿü ` ™rg •ÿü ` ™m OMatrix functions are math functions that are specific to matrix manipulations. 7 •ÿü ` ™ bEigenvalues and eigenvectors. EIG(X) is a vector containing the eigenvalues of a square matrix X. •ÿü ` ! ™ 1 d @ Ž Ñ • • a) a) 6 6 ø ¬ @ • Ó Ž û 6 “ 6 ø ¬ • ‘ 0ÿþ ` " © 0 >> y = eig(a) š w ` | ¬ þ $ ` # ¬ y = 2 ` $ ¬ = @ 16.1168 ` % ¬. -1.1168 N ` & ¬ \ } ¬(X s j -0.0000 ` ` ' ©em es, x ~ ¬ec † >> [U,D] = eig(a) ` ` ( ¬ÿþ ” U = ` ) ¬h ¢ 0.2320 0 .7858 ` 0.4082 * ¬ ° 0.5253 0.0868 -0.8165 ` + ¬su [ ¾ • ¬ † e Ì 0.8187 -0.6123 ` ` 0.4082 , ¬ Ú D = ` - ¬ÿþ i è 16.1168 ` 0 0 . ¬ 0 -1.1168 tio ö 0 ` / ¬ 0 € ¬un o 0 -0.0000 ` ` 0 ¬on a >> ` 1 ™ri a . ` 5 ™ÿü =UT UT ªª ` 2 -nv $9.1 Submatrices and colon notation. ct Kÿþ ` 3 ™ei v Yÿþ 4 ™ma gMatrices can be referenced as whole matrices or submatrices within larger matrices by way of colon ref 6 gÿþ 4 ™@ ierences. Colon notation can be used as an implied for loop with the syntax from:step:to which define the w uÿþ @ 4 ™ Iloop contraints. (the transposed) ƒÿþ ` ¬ Õ ™ denotes the matrix should be 8 ™ ‘ÿþ ` 9 © X Ÿÿþ >> x = [ 0.0:0.1:2.0 ]Õ ` : ¬ ' -ÿþ ` ; ¬a) »ÿþ x = ` < ¬ Ö Éÿþ ` = ¬ U 0 ” ×ÿþ ` > ¬ 0 78 åÿþ 0.1000 ` ? ¬ óÿþ 0.2000 ` @ ¬-0 ÿþ 0.3000 ` A ¬ 0 12 ÿþ 0.4000 ` B ¬ † ÿþ 0.5000 ` C ¬ , 0.6000 +ÿþ ` D ¬ÿþ 9ÿþ 0.7000 ` E ¬ Gÿþ 0.8000 ` F ¬ 0.9000 / Uÿþ ` G ¬00 cÿþ 1.0000 ` H ¬ 1.1000 0 qÿþ ` I ¬ ri •ÿþ 1.2000 ` J ¬ 5 1.3000 UT •ÿþ ` K ¬9. ce ›ÿþ 1.4000 ` L ¬on 1.5000 d @ • Ñ c ‘ ‘ s ol 6 6 ø ¬ @ ‘ Ó • r 6 “ 6 ø ¬ • “ 1@ ` M ¬ot be 1.6000 ` N ¬d it $ 1.7000 ` O ¬st h 2 1.8000 ` P ¬ @ 1.9000 ` Q ¬ ( ™ N 2.0000 ` R ¬ix \ ` S ¨ >> y = sin(x) ™ j ` T ¬ 9 x ` U ¬1: X † y = ` V ¬ ' 0 -ÿþ ” ` W ¬ x ¢ 0.0998 ` X ¬ ˆ 0.1987 = ° ` Y ¬ 0 ¾ 0.2955 ` Z ¬ Ì 0.3894 ` [ ¬ -0 Ú 0.4794 ` \ ¬ 0 è 0.5646 ` ] ¬ ö 0.6442 ` ^ ¬ 0.7174 , ` _ ¬ ÿþ 0.7833 ` ` ¬ 0.8415 ` a ¬ . 0.8912 ` b ¬ 00 < 0.9320 ` c ¬ J 0.9636 ` d ¬ X 0.9854 ` e ¬ 0.9975 5 f ` f ¬ 9. t 0.9996 ` g ¬ on ‚ 0.9917 ` h ¬ • 0.9738 ` i ¬ ž 0.9463 ` j ¬ol ¬ 0.9093 ` k ¬ º ` o ¨ È >> [x y] ` p ™ ¬ ans = Ö ` q ¬be ä 0 0 ` r ¬00 ` 0.1000 0.0998 O ò ` s ¬ 1 0.2000 0.1987 ` t ¬ ™ 0.3000 0.2955 ` u ¬ix ` 0.4000 0.3894 S ` v ¬x) ` 0.5000 0.4794 T * ` w ¬ † 8 0.6000 0.5646 ` x ¬ 0 ` 0.7000 0.6442 W F ` y ¬ 0 T 0.8000 0.7174 ` z ¬ 0 b 0.9000 0.7833 ` { ¬ p 1.0000 0.8415 ` | ¬79 ` 1.1000 0.8912 \ ~ ` } ¬ 0 Œ 1.2000 0.9320 ` ~ ¬ 1.3000 0.9636 , š ` • ¬ ¨ 1.4000 0.9854 ` € ¬41 ` 1.5000 0.9975 a d @ ’ Ñ 2 “ “ “ Ó ’ 0 6 6 ø ¬ @ 6 “ 6 ø ¬ ‘ • 0 ` • ¬ 991 1.6000 0.9996 ` ‚ ¬ h • 1.7000 0.9917 $ ` ƒ ¬ 0 2 1.8000 0.9738 ` „ ¬ ¬ @ 1.9000 0.9463 ` … ¬ o È 2.0000 0.9093 N ` † ¬ \ ` ‡ ¨ >> a(1:3,2) j ` ˆ ¬00 x ` ‰ ¬ ` ans = s † ` Š ¬87 ” ` ‹ ¬ 300 ¢ 2 ` Œ ¬ ` 5 u ° ` • ¬94 ¾ 8 ` Ž ¬ 0 Ì ` • ¨ >> a(1:3,3) 0 Ú ` • © è ` ‘ ¬00 ` ans = W ö ` ’ ¬ ` “ ¬ 3 ` ” ¬0. 0 6 ` • ¬ 000 . 9 ` – ¬ < ` — ¨0. >> a(1:2,2) J ` ˜ ©00 X ` ™ ¬ 1 f ans = ` š ¬ t ` › ¬00 854 ‚ 2 ` œ ¬ € 5 1 • ` • ¬ ž ` ž ¨ Ñ >> a(2:3,2) 2 ¬ ` Ÿ ¬ º ` ¬ “ Ó È ans = ` ¡ ¬ ø Ö 5 ` ¢ ¬ 8 ä ` £ ¬ ò ` ¤ ¬96 >> ` l ¤ 1 0 ` ¤ ` ¤0. 8 +UT UT ªª ` ç - „ 10.1 Output Format. 9ÿþ ` Ý ™ o 2 Gÿþ ` è © >> a = 1 Uÿþ ` é © > cÿþ ¬ a = ` ê ¬ ` 1 ˆ qÿþ ` ë © >> a = 1.2 = •ÿþ ` ì ¬ Š a = •ÿþ ` í ¬ ›ÿþ 1.2000 ` î © 5 • ” Ñ >> format short d @ 0 6 6 • • ø ¬ 3, @ • Ó ” 0 6 “ 6 ø ¬ ž ž “ — ` ï © >> a = 1.2 0. ` ð ¬ $ a = ` ñ ¬ 2 1.2000 ` ò ©0. @ >> format long ` ó © >> a = 1.2 ™ N ` ô ¬ \ a = ` õ ¬ ‚ j 1.20000000000000 ` ö © 5 ¬ x >> format short e ` ÷ © ž >> a = 1.2 3, † ` ø ¬ Ÿ a = ” ` ù ¬ Ó ¢ 1.20000 ` ¤ 5 ° ¤ ` ¢ £ 2 ¤ ¦ ¼ 1 ¾ ` ¤ Ì ` ¤ Ú ` ¤ è ` ¤ ö ` ¤ UT UT ªª ` -UT 11.1 Graphics. O ÿþ ` ™ÿþ !ÿþ ` ½ ™ÿþ /ÿþ ` ¾ ™a "Example one plots out a sin curve =ÿþ ` ¿ ™ 1 Kÿþ ` ™ ë ¨ >> x = -4:0.01:4; Yÿþ ` ¨ >> y = sin(x); gÿþ ` ¨ , >> plot(x,y), title(ÔExample Sin curve.Õ); uÿþ ` ¨ >> ƒÿþ ™ , ‘ÿþ ™ ` h e ƒ • - ™ ` 0 Fig1: Section 13 example plot. ‘ • ` ™ Ÿ • ` ™1. . d @ – Ñ ñ — — 6 6 ø ¬ @ — Ó – ó 6 “ 6 ø ¬ ª ¢ • ™ Æ ™ lThis example shows how to change the color and linetype of the plotted figure. Use ¨ help plot ™ to see @ Æ ™ )more information about the plot command. $ ` À ™ 2 ` £ ¨ >> x = -1.5:0.01:1.5; @ ` Á ¨ >> y = exp(-x.^2); N `  ¨ >> plot(x,y,Õ--gÕ) © UT \ h È © G m . 2(õ ` Ì © þ @(õ ` Í ™ ½ Fig2: Section 13 example plot. mpl N(õ ` Ê ©si u \(õ ™ ¿ fThis is a bit more extensive example of how to plot a mesh of values. This may be usefull to show spa j(õ @ ™pl Atially related data and the relationship and tendencies of data. x(õ ` ™ , †(õ ` à ¨ >> xx = -2:.1:2; ”(õ ` % ¨ct >> yy = xx; p ¢(õ ` & ¨ >> [x,y] = meshdom(xx,yy); 1. °(õ ` ' ¨ >> z = exp(-x.^2 - y.^2); ¾(õ h ( ¨ / >> mesh(z), title(ÔNeat mesh plot.Õ); © f 6 ”Qê ` Ë © ™ ¢Qê ` 1 ™ Fig2: Section 13 example plot. e s d @ ˜ Ñ f ™ ™ se ¨ 6 $ ø Ð @ ™ Ó ˜ 6 “ $ ø Ð ¤ ¤ — $ UT UT ªª ` ¹ +An additional example of function plotting UR UT ªª ` ß ® > 'ÿü 4 ™ mThe First Derivative test for Relative Extrema. This example will use the derivative of a function to locate 5ÿü @ 4 ™ct Yits relative maximum points. The theorem for testing for relative extrema is defined as: t Cÿü ` 7 ™ho o Qÿü 8 ™lu ~ If ¦ f ™ has a relative minimum or relative maximum when x = c, then either (i) ¦ fÕ(c) ™ = 0 or (ii) ¦ fÕ(c) ™ is _ÿü 8 ™ , tundefined. That is, c is a critical number of ¦ f ™ . Based on this theorem, locate all relative extrema for the xx mÿü @ 8 ™ function: {ÿü ` = ™y. ; ‰ÿü ` > ™ ( 1 ¦ f(x) = 2x § 3 ¦ - 3x § 2 ¦ - 36x + 14 —ÿü ` ? ™ Ë ¥ÿü ` @ ™ 1 HSolution: By setting the derivative of ¦ f ™ equal to zero, we have ³ÿü ` A ™ ™ Áÿü ` B ™ & ¦ fÕ(x) = 6x ¯ 2 ¦ -6x - 36 = 0 Ïÿü ` C ¦ 6(x ¯ 2 ¦ - x - 6) = 0 UT Ýÿü ` D ¦dd 6(x - 3)(x + 2) = 0 ëÿü ` E ™UR T ùÿü F ™ÿü ~ Since ¦ f ™ Õ is defined for all real numbers, the only critical numbers of ¦ f ™ are -2 and 3. To test this proof we ÿü F ™ct mcan create matrices to represent our function and an interval to operate on, the interval should include the o ÿü F ™ 8 iabove stated critical numbers. To create the interval using arrays, use the colon notation: (remember to #ÿü @ F ™™ ;use the Array operator notation (.^) for the powers of x). nu 1ÿü ` ™ B d ?ÿü M ¨lo >> m Mÿü N ¨ 0 >> ÿü [ÿü O ¨ 5 >> iÿü P ¨ÿü >> grid; wÿü Q ¨ s >> f …ÿü R ¨we >> “ÿü S ¨ 0 ¡ÿü T © 2 ¯ÿü U ¬x 2) ½ÿü V ¬ E 4 >> in Ëÿü W ¬mb n Ùÿü X ¬ s çÿü ` ™ÿü Âûã ` X = -4.0:.1:5.0; ` FofX = 2.0*X.^3 - 3.0*X.^2 - 36.0*X + 14.0; ` plot(X,FofX),title(ÔTest for Relative ExtremaÕ); ` ` [Y,Max_I) = max(FofX); ` [Y,Min_I) = min(FofX); ` >> Relative_Maximum = [ X(Max_I) FofX(Max_I) ] ` ¬ Relative_Maximum = ` -2 58 ` ¨ Relative_Minimum = [ X(Min_I) FofX(Min_I) ] ` Relative_Minimum = ` 3.0000 -67.0000 h g ` à ™te 8Figure 3: Plot of results to Test for Relative Extrema. ra í À @¼ š Ó ¤ ü í À ¯ c <c>Screen7.ras H ™ Ô mem r H ™ ™ Q « ¹ of ). Q « « •\ Ëÿþ "áG ã • @ œ Ø ƒ • ‚ @ @ ž Ó • Ù œ ¦ ‚ ” o H . Q ™ Ô « ¹ N ¡ ¡ d • e @ Ñ * O t ¨ ¨ ÿþ £• Ö ` ÿþ £• Ö ` @0 ¡ Ó – ž P <c>Screen4.ras ¯m‘ ø(õ $Ý È(õ @ ¢ Ó ª – ; « « — f we > ´ ÿü ü Ìûç @ ¤ Ó ˜ S = H e_M š š Ô Q im Q 6 6 ™ g ø ¬ im @ ¦ Ø • § ‚ ¹ @ @ ¨ Ó § Ù ¦ T H ‚ Ô E Q ve_ xi H ¹ t 6 ” 6 ™ ` ¯m‘ – ø ¬ -6 $Ý È(õ ` @v ª Ó ¢ – ¼ ¬ ¬ — m ö · t r È ö · @• « Ó ¢ <c>Screen6.ras ö · ö · È @Œ ¬ Ó ª <c>Screen5.ras n o ÿþ ) d Rightf ). d Reference @ m d @ Left d ‚ No Footere d „ d † * d ˆ O d Ž Š <c d Ó d • Œ (õ d £• d ’ ; d Ó š ” d d > d – ˜ No Footer 5 u U % æf ™ 5 ½ æf m ™ Body . 6 ½ æf ™ CellBody 7 . ½ CellHeading . æf ½ ™ e 8 Footnote . æf ™ 9 T ½ Heading Body . æf ™ : ¤ matout ½ . æf H ™ • ; ¤ ~ ´ ½ æf h æf 5 matout ™ H ~ . < ™ Ø ½ æf Body ™ . = ™ ½ æf Body ™ . > ™ ½ CellHeading . æf ™ ? ™ ½ æf ™ CellBody @ œ T . ½ TableTitle T:Table <n+>: . À @ ½ der ü A › ™ ü B › . . À @ ½ ø Footer . æf ™ C ¤ ø Hea matout ½ . æf H ™ æf ´ D ™ ™ ü ½ Body . æf ™ E ¤ Ø ½ matout æf H ~ . ™ F ¢ ½ H ~ À Ta ¢ ½ ter le @ ü matout G › ™ ø . æf ™ H ™ . Foo ½ . ot æf Z ™ Body I ª ½ Z Body . æf ™ J © ½ H ~ æf ¢ ™ matout K ¤ . ½ H ~ Ø h matout æf . ™ L ™ ½ ~ ¢ æf ½ æf matout ™ ™ . M • Body N © . ½ æf ™ Body O ¤ . ½ æf Body ™ . P ¤ matout ½ . æf 9™™ ™ l Q ¤ • matout ½ . æf H ™ ~ R ® ¢ ½ æf ™ Body S ™ . ½ æf Body ™ . T ¤ ½ Body H ~ . æf ™ V ™ æf ´ ½ . Body . æf ™ W © ½ . Body . æf ™ [ ¤ ½ z æf f matout ™ 6 ~ . ^ ¤ ¤ Æ ½ ê 2 æf 6 matout ™ ~ . a ¤ ´ ½ Æ matout H . ™ ¹ ° Bo ~ . zÙVÓ ™ ½ ;cóo š zÙVÓ › ½ ½ ReadOut îãø œ ½ € Emphasis Subscript Superscript îãø • ž ½ ½ Ÿ ½ ½ © - ¡ ½ æf ÷3 îãø ¢ ½ Titles zÙVÓ £ ½ TypeIn æ_ý‰ ¤ ½ ÷3 ;cóo ¥ ½ TypeIn h°„² ¦ ½ Emphasis h°„² § ½ Emphasis ;cóo ¨ ½ TypeIn ;cóo © ½ h°„² ª ½ ÷3 æ_ý‰ « ½ ReadOutÆ æ_ý‰ ¬ ½ ReadOut îãø - ½ Titles îãø ® ½ h°„² ¯ Superscriptœ bles Ñ á Ô Ó € ½ € ½ Ñ ½ × ÿÿØ; ½ ± ø Ò Õ ½ Ø EquationVaria ½ Ö ½ ½ Z € Ù ½ Z b d Å a ½ ½ Õ Å q Medium Thick‰ f € @ € c e a ½ ½ ½ Thin Double Very Thin Æ a a c @ ½ ½ ½ > ? > H a > ? > a a a a a a H H > ? > > ? > Format ATy H > ? > H Ç a a b @ ½ ½ ½ > ? > H ) 9 ) * ¿ > ? > Commentî H H > ? > a > ? > Format B b a H ! 1 # a > ? > =Ö ! a H u h i =Ù " v j k ½ Í Å ½ Black Su ¿Eq Redn d d Á Blue d Magenta d Times-Roman½ Times-Bold Courier d • À T! ¾ White Green ½ d  ½ Cyan Ä€ Yellow d d A d d à Courier-Bold Times-Italic Helvetica-Bold Courier Times Helveticae Regular½ Regular Bold RegularT Italic Ã^çÏ¢ át”åA[£Æ›#a½©ñ ³ îq×¾(Ùå¼¢tH ðw†-òr /V{°Ó…;ºË!PLGM”^îH¥mõ ¢ ‰ž@/Ýè„‘÷ ¹Eˆ#³hj}(Ô ápªV9‰LŠ 'ëR7D¡ÉB ØahšÛC¤RìHÿ< 2˜À4Y²Ÿ^lÔ=ô?»øœÐ0Ù#Ó2âè ìÁ°KC†®Mîê Ø0§±ˆÿÏÆ›¿DÂ1w•<t¶WÏ