Basics of Matlab
Basics of Matlab
Basics of Matlab
S(USA)
MATLAB
A L ANGUAGE OF TECHNICAL COMPUTING
ER.SOUMEN CHATTERJEE
B.Tech,M.S(USA),Member of Springer Online igital !ibrar"
MATLAB
1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
The Matri# laborator" pac$age referre% to a& Matlab 'a& originall" %e&igne% to &er(e a& a tool for numerical computation librarie& !)*+AC, an% E)S+AC, that 'ere u&e% for %ealing e-uation&. But,it 'a& too length" an% har% to 'or$ on &imultaneou& both the &oft'are&.Thu&,MAT!AB ha& been %e&igne% for &uch purpo&e 'hich are./
Math an% computation. Algorithm %e(elopment. ata ac-ui&ition.. Mo%elling, &imulation, an% protot"ping. ata anal"&i&, e#ploration, an% (i&uali3ation. Scientific an% engineering graphic&. Application %e(elopment, inclu%ing graphical u&er interface buil%ing. The Matlab &oft'are 'a& originall" %e(elope% at the Uni(er&it" of *e' Me#ico an% Stanfor% Uni(er&it", USA in the 0456&. Mr.7ac$ !ittle an% Mr.Cli(e Moler ha& &oon &et up a compan" $no'n a& math'or$.The 'eb&ite for math 'or$ i& http.88'''.math'or$&.in8 . The &oft'are i& to &pen% time in learning the ph"&ical an% mathematical principle& of a problem an% not about the &oft'are. So, 'hat are the &pecialitie& of Matlab then an" other &oft'are. The Ba&ic %ifference& are./
Srl *o 0 1
Matlab
)t e#ecute& one in&truction at a time. B" anal"&ing partial re&ult& an% ba&e% on the&e re&ult&, ne' in&truction& can be e#ecute% that interact 'ith the e#i&ting information alrea%" &tore% in the comman% hi&tor" or computer memor". MAT!AB i& a (er" po'erful mathematical engine 'ith 'i%e range of toolbo#e& an% other tool&, e.g S)MU!)*,. )t can be u&e% for nearl" e(er"thing :on &"&tem le(el: MAT!AB can ha(e &imulation an% graphical interface
Getting Started
=or getting &tarte% fir&t %ouble clic$ on to the icon Matlab 2010a an% it 'ill open.There are certain %e&$top tool& 'hich are u&eful for un%er&tan%ing Matlab an% tho&e are./
Desktop Tools
The following tools are managed by the MATLAB desktop, although not all of them appear by default when you first start. If you prefer a command line interface, you can use functions to perform most of the features found in the MATLAB desktop tools. Instructions for using these function equi alents are pro ided with the documentation for each tool. Comman% 9in%o' > ?un MAT!AB function&. Comman% @i&tor" > Aie' a log of the function& "ou entere% in the Comman% 'in%o', cop" them, an% e#ecute them. !aunch +a% > ?un tool& an% acce&& %ocumentation for all of "our Math9or$& pro%uct&.
Current irector" Bro'&er > Aie' MAT!AB file& an% relate% file&, an% perform file operation& &uch a& open, an% fin% content.
@elp Bro'&er > Aie' an% &earch the %ocumentation for the full famil" of MAT!AB pro%uct&. 9or$&pace Bro'&er > Aie' an% ma$e change& to the content& of the 'or$&pace. Arra" E%itor > Aie' arra" content& in a table format an% e%it the (alue&.
2
Er.Soumen Chatterjee,B.Tech,M.S(USA)
E%itor8 ebugger > Create, e%it, an% %ebug M/file& (file& containing MAT!AB function&). Other MAT!AB tool& an% 'in%o'&, &uch a& figure 'in%o'&, are not manage% b" the %e&$top.
#orkspace Browser shows $ariables defined in workspace
Si%ulink Browser
Command History windows displays pre'ious &ommands Paste Undo Guide Profiler Help
'urrent Directory Browser Gi$es the details of the files in the current directory
Copy
Redo
Simulink rowser
Current Folder
i()
ACD 0F1F2E AC 0 1 2
(%portant Facts
Matlab %oe¬ care about &pacing e#cept 'hen 'or$ing 'ith comple# number. *umber& &uch a& HG,666,666 can be e#pre&&e% a& H.Ge5. )f a mi&ta$e i& ma%e in entering an in&truction, cau&ing an error me&&age, then the 'hole in&truction mu&t be ret"pe% or reentere%. *o character& can be mo%ifie% in the comman% 'in%o' after the JenterB $e" i& pre&&e%. The ret"ping can be a(oi%e% b" pre&&ing the up an% %o'n $e". That action repeat& the la&t in&truction& an% the error can then be correcte% 'ith the nee% of ret"ping. Matlab (ariable& name& are ca&e &en&iti(e an% in general, Aa i& not e-ual to aA i& not e-ual to AA i& not e-ual to aa. Matlab re&er(e& &pecial (ariable& name& to repre&ent a function or a particular con&tant. The rea%er &houl%n<t create (ariable& the&e name&. An& Computer Aer&ion Aer !icen&e +i E#p(0) Ep& ?ealmin ?ealma# Bitma# =lop& )nf *an ) or j )nput ate Temporar" (ariable that &tore& the mo&t recent an&'er. ?eturen& the computer t"pe. Matlab (er&ion. ?eturn& the information about the licen&e an% (er&ion of the Matlab pac$age !icen&e information KC2.0;0G4.. The (alue of eC1.50 ?epre&ent& the accurac" of floating point, the &malle&t po&&ible po&iti(e number The &malle&t real po&iti(e number. The large&t real po&iti(e number. The large&t po&iti(e integer Count& of the floating point operation& ?epre&ent& infinit"(086) *on a number The (alue of root(/0) %enote& the imaginar" part of a comple# number Accept& information (ia $e"boar% ?epre&ent& the current %ate a& a &tring. (
Er.Soumen Chatterjee,B.Tech,M.S(USA) ?epere&ent& current %ate an% time a& E#ecute& a beep &oun%. Mea&ure& the time bet'een the tic an% toc a& a &top'atch. Stop& e#ecuting a program momentaril". Stop& e#ecuting a program %uring n &econ%&.
Matlab perform& calculation& ba&e% on a la&t (alue a&&igne% to a (ariable. The comman% clear %elete& all the (ariable& %efine% b" a u&er. The clear comman% can be &electi(e &uch a& clear A,Aa, %eleting onl" the in%icate% (ariable&. The comman% clc clear& the comman% 'in%o', but %oe&n<t %elete the (ariable& %efine% earlier. The comman% clf clear the figure 'in%o'. The comman% 'ho& li&t& the (ariable& currentl" u&e% in the 'or$&pace. Eg BB aCmagic(;) aC 0H 1 G 00 4 5 ; 0; BB 'ho& *ame 2 02 06 I H 01 0G 0 Si3e B"te& Cla&& Attribute&
a ;#; 01I %ouble Stan%ar% mathematical e#pre&&ion& are e(aluate% from left to right,follo'ing rule&. The &tan%ar% matlab algebraic &"mbol& an% &ome &imple function& are %efine%. A comment &tatement &tarting 'ith the percentage &"mbol( L) %oe&n<t affect an" e#ecutable Matlab in&truction an% can<t be continue% on the ne#t line. Multiple &tatement& can be place% on one line 'hen the" are &eparate% b" a comma(,) or &emicolon(F) A &emicolon (F) at the en% of an in&truction &uppre&&e& the echo, 'herea& a comma %oe&n<t. Matlab can be aborte% or interrupte% at an" time b" pre&&ing the 'trl and ' keys &imultaneou&l" (thi& action abort& a running Matlab program). Matlab in general i& al'a"& a ca&e &en&iti(e an% matlab comman%& an% function& al'a"& u&e lo'erca&e character&. Matlab file& 'ith e#ten&ion m are reffere% a& M file&.
Matlab accept& t'o t"pe& of %ata file&. MAT!AB an% ASC)) file&.
#orkspace and Array !ditor 9hen "ou i&&ue comman%& li$e. BB#C06F BB"CD0 1 2 ;EF LArra" Aariable Matlab create& (ariable& name& M an% N, an% &a(e& them in a part of computer memor" $no'n a& 'or$&pace.Nou can ob&er(e the content& of the 'or$&pace b" t"ping 'ho& comman%. ouble clic$ing on an" (ariable in the 'or$&pace bro'&er 'in%o' bring& up the arra" e%itor 'hich allo'& the u&er to ob&er(e an% mo%if" the information &tore% in the (ariable. An" (ariable on 'or$&pace can be manipulate% u&ing the arra" e%itor. Change the (alue& Change the Change& the %imen& MATLAB of arra" element& %i&pla" format of the arra" #orkspace
Er.Soumen Chatterjee,B.Tech,M.S(USA)
)ath Browser The +ath Bro'&er allo'& "ou to (ie' an% mo%if" the MAT!AB &earch path. )t allo'& the u&er to a%%, %elete, or change the or%er of %irectorie& in the path. Ma$e &ure that the fol%er 'here "ou ha(e &a(e% "our M/file e#i&t& in MAT!AB +ath, other'i&e it 'on<t be e#ecute%. Al&o, if there are more than one function&, comman%& or &cript file& (M/file&) 'ith the &ame name, the fir&t one foun% in the &earch path 'ill be e#ecute% an% all the other& 'ill be inacce&&ible. Therefore* it is e+tre%ely i%portant not to define a $ariable with the sa%e na%e as a standard MATLAB function or co%%and* which will %ake that function inaccessible ,, #riting Si%ple !+pressions Unli$e man" other programing language&, "ou nee% not %eclare the t"pe of (alue& a (ariable can ta$e in MAT!AB. =or e#ample, a (ariable a can ta$e an integer (alue, an% in the ne#t &tep, "ou can a&&ign the &ame (ariable a float (alue an% in the thir% &tep, "ou can a&&ign it a &tring an% &o on. ** new'ar+,soumennew'ar + soumen The paranthe&e& () are u&e% in comple# operation&. Other brace&( &uch a& OP an% DE) are re&er(e% for &pecial purpo&e& in Matlab.@ere are &ome e#ample&. Mathematical E#pre&&ion& Matlab Co%e -. + / 0y 1 2 3y4+ + / 05y 1 25 3y4+ 0. 0 +2 / 67+6 2.
6+
-72 / 9 y:.-;2
Er.Soumen Chatterjee,B.Tech,M.S(USA) !+ercise -= U&e MAT!AB to ma$e the follo'ing calculation&, for gi(en (alue& of # an% chec$ the re&ult& 'ith the help of a calculator. " C ( 0 > 08#2)/0, #C1 " C 2Q. #1, # C 2 " C 5(#082) R ;#6.GI, # C 16 " C elog(#), # C 2 !+ercise 0= Si(en an e#pre&&ion. f C # R 1 O" > 2 (3/t)P, e#plain 'ith the rea&oning 'hat are the problem& 'ith the follo'ing co%e& in MAT!AB. f C # R 1 O" > 2 (3/t)P f C # R 1TD" > 2 (3/t)E f C # R 1 (" > 2 (3/t)) f C # R 1T(" > 2 (3/t)) Sub&e-uentl", 'rite the correct co%e for the e#pre&&ion an% compute it 'ith the (alue& # C 1, " C 2, 3 C G an% t C 5.
Matrices and Arrays Matlab 'or$& 'ith onl" a &ingle object t"pe, the matlab arra". All matlab (ariable&, inclu%ing &calar&, (ector&, matrice& etc. are &tore% a& matlab arra"&. 9hen the arra" ha& onl" one %imen&ion ( either a ro' or a column) it i& $no'n a& a (ector, 'hile t'o or more %imen&ional arra" i& $no'n a& matri#.)t i& important to $no' that in matlab e(en a &calar i& treate% a& an arra" 'ith %imen&ion 0#0. A character &tring i& al&o treate% a& an arra". BB A0CD0 1 2 ; GE A0 C 0 1 2 ; G LA1 i& a (ectorL LA0 i& a (ector.
BB A1CD0 1 2 ; GE A1 C 0 1 2 ; G
LB i& a matri#L
The element& of a (ector or a matri# are acce&&e% u&ing parenthe&e& operator. )n&i%e the parenthe&e& i& the in%e# of the element. BB A0(1) an& C 1 BB B(0,2)
/
Er.Soumen Chatterjee,B.Tech,M.S(USA)
an& C 5 The length of a (ector can be %etermine% b" length comman%, 'herea& the or%er of a matri# i&
%etermine% u&ing &i3e comman%. BB ACD0 1 2 ; GE AC 0 1 2 BB length(A) an& C G ; G
BB &i3e(B) an& C
2 2 Sitara% >> length3' ans ? ; BB CCUSoumenU CC Soumen BB length(C) an& C H BB C(length(C)/1) an& C m BB C(en%) an& C 0 Le-ui(alent to 'riting BBc(5/1)
Er.Soumen Chatterjee,B.Tech,M.S(USA) n Nou can al&o acce&& the la&t element in a (ector u&ing en% (ariable a& &ho'n belo'./ BB C(en%) an& C n 'olon Aperator Another important 'a" to create (ector& i& to u&e the colon notation 3= . Thi& i& e&peciall" u&eful if the (ector element& are to be uniforml" &pace%. A general metho% to create a (ector A i& a& follo'&. L Acce&& the la&t element
" ? s=d=f where* s? &tart or initial (alue d? increment8%ecrement &tep f? en% or final (alue The $ector " then contains ele%ents Bs s/d s/0Cd s/2Cd D s/kCdE where k is chosen such that s/kCd less than or eFual to f. The following e+a%ples illustrate the use of colon operator as=4 BB EC0.06.066 EC 0 00 10 20 ;0 G0 H0 50 I0 40
Thi& Metho% particularl" u&eful in %e&igning plot& or graphic& in 1% an% 2% format.
BB SC0.1.06 SC 0 2 G 5 4
BB M C 1Tpi./pi81./1Tpi////////////////////////////colon operator e#ample MC Column& 0 through I H.1I21 Column 4 /H.1I21 9hen increment8%ecrement &tep % i& omitte%, MAT!AB a&&ume& %C0.=ollo'ing are &ome e#ample& u&ing the colon operator to generate (ector&.
1
;.501;
2.0;0H
0.G56I
Er.Soumen Chatterjee,B.Tech,M.S(USA)
BB CC16.26 CC 16 10 11 12 1; 1G 1H 15 1I 14 26
The Magic Function MAT!AB actuall" ha& a built/in function that create& magic &-uare& of almo&t an" &i3e. *ot &urpri&ingl", thi& function i& name% magic. BB ACmagic(;) AC 0H 1 G 00 4 5 ; 0; 2 02 06 I H 01 0G 0
Thi& i& one of the rea%"ma%e matri# 'here "ou %on<t ha(e to t"pe the element&. +lu&, "ou can practice "our&elf 'ith the help of &uch mati# for "our o'n learning in Matlab
BB Cmagic(2) C I 2 ; 0 G 4 H 5 1
BB =Cmagic(1) =C 0 ; 2 1
BB SCmagic(G) SC 05 12 ; 06 00 1; 0 I 0G G 5 0; 0H H 02 16 11 01 04 10 2 0I 1G 1 4
12
Er.Soumen Chatterjee,B.Tech,M.S(USA)
'oncatenation )t i& the proce&& of joining &mall matrice& to ma$e bigger one&. )n fact, "ou ma%e "our fir&t matric b" concatenating it& in(i%u%ual element&, The pair of &-uare brac$et& D E i& the concatenation operator. A& for e#ample the ;/b"/; magic &-uare A an% form can be 'ritten a&./ BB ACmagic(;)/////////////////////////////////e#ample 0 AC 0H 1 G 00 4 5 ; 0; 2 02 06 I H 01 0G 0
Another important 'a" to create uniforml" &eparate% element& in a (ector b" lin&pace comman%&. Linspace 'o%%ands BBlin&pace(#0, #1, n) generate& n point& bet'een t'o number& #0 an% #1. =or n J 1, lin&pace return& #1. Such a& the e-ual %i&tance bet'een the t'o point& 'ill be of M1 for eg BB VClin&pace(066,16,4) VC 066 46 I6 56 H6 Logspace 'o%%ands G6 ;6 26 16
N C log&pace(#0,#1,n) )n thi& ca&e, the fir&t element of the re&ultant arra" W"<, i& 06 #0 , the la&t
element i& 06#1 an% the total number of element i& n. The follo'ing are the e#ample&./
BB ?Clog&pace(0,G,G) ?C 06 066 0666 06666 066666
Er.Soumen Chatterjee,B.Tech,M.S(USA)
NC 0 1 00 2 2 ; 4 ; G H 5 G
BB N(2,0) an& C 00 BB N(1,2) an& C H BB N(1,;) XXX )n%e# e#cee%& matri# %imen&ion&. A(1,;) re&ult& in an error becau&e the matri# A ha& onl" 2 column& eleting the rows an% colu%n eleting the ro'& BB N(1 ,.)CD E L Thi& e#pre&&ion implie& that the 0 &t ro' of the matri# get& the ne' (alue a& a null(ector i.e fir&t ro' i& eliminate%. NC 0 00 2 2 4 ; G 5 G
)f "ou 'ant to get all the element& in one &ingle column . Then, the proce%ure./ BB NCD0 2 GF1 ; HF00 4 5F2 ; GE NC
12
Er.Soumen Chatterjee,B.Tech,M.S(USA)
0 1 00 2 BB N(.) an& C 0 1 00 2 2 ; 4 ; G H 5 G
2 ; 4 ;
G H 5 G
)n&ert an" ne' element into the matri# a& &uch./ BB N(2,1)C1 NC 0 1 00 2 2 ; 1 ; G H 5 G
BB N(1,;)CI NC 0 1 00 2 2 ; 1 ; G H 5 G 6 I 6 6
'reating so%e special %atrices There are &ome &pecial comman%& li$e one&,3ero& an% e"e in Matlab create& &pecial matrice&. The&e are e&peciall" u&efull for intial3ing all the element& of matri# to a particular (alue. !et u& &a" "ou 'ant to create a matri# 'ith all of it& element& initiali3e% to a (alue 2. BB AC2Tone&(1,;) AC
1!
Er.Soumen Chatterjee,B.Tech,M.S(USA)
2 2
2 2
2 2
2 2
Similarl" "ou can create a matri# 'ith all of it& element& initiali3e% to 3ero 'ith another &pecial functiom& Geros= BB BC3ero&(2) BC 6 6 6 6 6 6 6 6 6
(dentity Matri+ An )%entit" matri# of or%er 2#2 can be create% u&ing e"e comman% a& &ho'n ne#t. BB CCe"e(2) CC 0 6 6 6 0 6 6 6 0
)n man" application& &uch a& neural net'or$8fu33" logic8 )mage proce&&ing there i& a re-uirement& of ran%om number generation.The comman% rand generate& a matri# 'ith ran%oml" generate% number& cho&en from a uniform %i&tribution on the inter(al (6.6, 0.6) BB Cran%(1,;) C 6.I0;5 6.46GI 6.0156 6.402; 6.H21; 6.645G 6.15IG 6.G;H4
9e can al&o place t'o matrice& &i%e b" &i%e 'hich call a& Aug%ented Matrices BB =C;Tone&(1,1) =C ; ; ; ;
BB @Cone&(1,1) @C 0 0 0 0
BB @Ce"e(1,1)
1(
Er.Soumen Chatterjee,B.Tech,M.S(USA)
@C 0 6 6 0
BB 7CD=F@E 7C ; ; 0 6 ; ; 6 0
BB 7CD= @E 7C ; ; ; ; 0 6 6 0
Aperators The Matri# operator& can be %i(i%e% into three %ifferent categorie&. 3a Matri+ operators for general use. 3b Relational Aperators. 3c Logical Aperators
S"mbol
/ 4 7 H 5 8
=unction &uch a& &-rt,.log
Operation A%%ition Subtraction ?ight i(i&ion !eft i(i&ion Multiplication E#ponentiation S-uare root log 1
The or%er of prece%ence for the&e operator& i& a& follo'&. 8 7 H 5 / 4 The or%er of prece%ence can be mo%ifie% b" u&ing the parenthe&i& W( )< 'hich get& the highe&t priorit"
Nou can appl" &calar multiplication, a%%ition, &ub&traction an% po'er operator& on a (ector an% matrice& u&ing the abo(e e#ample&.
3A
AC
Matri+ Aperators
@ere a%%ition of 1 change% the matri# element& but not the %imen&ion&. 1)
BB ACD0 1 2 ; GE
Er.Soumen Chatterjee,B.Tech,M.S(USA)
BB BCAR1 BC 2 ; G H 5
BB CCD1 2 ;ET(1R2[1) CC 11 22 ;;
BB +CD0 1F2 ;E +C 0 2 1 ;
BB =C+[1 =C 5 06 0G 11 BB ACD1 2 ;E/D0 1 2E AC 0 0 0 L&ub&traction of t'o (ector& are po&&ible of e-ual length
BB ACD1 2 ;E/D0 2E L&ub&traction of t'o (ector& are not po&&ible of une-ual length III !rror using ??> %inus Matri+ di%ensions %ust agree. Transpose of a %atri+ BB BCD0 1 2F; G HF5 I 4E BC 0 ; 5 BB BU an& C
1.
1 G I
2 H 4
Er.Soumen Chatterjee,B.Tech,M.S(USA)
0 ; 5
1 G I
2 H 4
BB &um(BU)U an& C 01 0G 0I To %easure a diagonal BB %iag(BU) an& C 0 G 4 =or matrice& u&ing comple# number the tran&po&e comman% hol%& goo% for them to han%le 'ith preci&ion. BB ,CD1R2i,1/2iF0Ri,0/iE ,C 1.6666 R 2.6666i 0.6666 R 0.6666i BB ,U an& C 1.6666 / 2.6666i 1.6666 R 2.6666i 0.6666 / 0.6666i 0.6666 R 0.6666i 1.6666 / 2.6666i 0.6666 / 0.6666i
A comment can be put on matlab in&truction& u&ing percentage &"mbol(L) %oe&n<t affect an" e#ecutable MAT!AB in&truction, an% can<t be continue% on the ne#t line. A= [1 3 4 5] JKo.of ele%ents in AJ BC D1 ; 0 0E JKo. of ele%ents in BJ CCARB JAddition of two nu%bersJ Multiple &tatement& can be place% on one olne 'hen the" are &eparate% b" a comma(,) or &emicolon(F). BB CD0,1,2,;E C 0 1 2 ;
BB #CD0F1F2F;E
1/
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Backslash or left %atri+ di$ide LHM=)f A an% B are t'o matrice&, AHB is the %atri+ di$ision of A into B* which i& roughl" the &ame a& ()n(er&e of A)\B , e#cept it i& compute% in a %ifferent 'a". M C AZB i& the &olution to the e-uation ATM C B compute% b" Sau&&ian elimination. )n other 'or%&, u&ing bac$&la&h operator, "ou can -uic$l" &ol(e man" e-uation&. For Left Di$ision The !eft %i(i&ion i& u&e% to &ol(e the matri# e-uation A#CB 'here # an% B are column (ector&. Multipl"ing both &i%e& of thi& e-uation b" the in(er&e of A , A /0 , 'e ha(e A/0 A#C A/0 B )#C#C A/0 B @ence, #C A/0 B So, 'e can 'rite./ #CAZB. For Right Di$ision
10
Er.Soumen Chatterjee,B.Tech,M.S(USA)
The right %i(i&ion i& u&e% to &ol(e the matri# e-uation& # ACB 'here # an% B are ro' (ector&. Multipl"ing both &i%e& of thi& e-uation b" the in(er&e of A, A /0, 'e ha(e. # T A A/0C B T A/0 #C B T A/0 So, 'e can 'rite #CB8A. BB ACD0 1F2 ;E AC 0 2 1 ;
BB BCmagic(1) BC 0 ; 2 1
BB CCAZB '? 0.:::: 4<.:::: 4:.6::: 2.6::: Sla&h or right matri# %i(i%e W8<. )f A an% B are t'o matrice&, A8B i& the matri# %i(i&ion of B into A. A8B i& roughl" the &ame a& A\()n(er&e of B).
BB ACD0 1F2 ;E AC 0 2 1 ;
BB BCmagic(1) BC 0 ; 2 1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
-.::::
:.6:::
Nou can (erif" that A8B i& appro#imatel" e-ual to A\()n(er&e of B) a& &ho'n belo'. BB SCin((B) SC /6.1666 6.2666 6.;666 /6.0666 BB @CATS @C :.N::: -.:::: :.-::: :.6:::
Array Aperations Mo&t of the operator& %i&cu&&e% abo$e 3such as 5* 8 or 7 * if preceded by a dot 3. re&ult in an element b" element operation (al&o $no'n a& arra" operator&) . Accor%ingl" the&e operator& $no'n a& arra" operator&. Array Multiplication BB !CD0 1 2E !C 0 1 2
#hat is an ArrayI An array i& a &"&tematic arrangement of object&, u&uall" in ro'& an% column&.)f "ou u&e it in an"'here it 'ill be arra".A& &uch, if no.of &tu%ent& in cla&& an% %i(i%e% into three group& E0,E1,E2 then the&e are calle% a& A??AN.
BB MCD1 2 ;E MC 1 2 ;
BB SC!.TM SC 1 H 01
BB SC!TM III !rror using ??> %ti%es (nner %atri+ di%ensions %ust agree. Array )ower BB SC!.[M
22
Er.Soumen Chatterjee,B.Tech,M.S(USA)
SC 0 I I0
BB SC![M III !rror using ??> %power (nputs %ust be a scalar and a sFuare %atri+. Array O7P or OHP Di$ision BB SC!.8M SC 6.G666 6.HHH5 BB SC!8M SC 6.HI45 Nou can e(en %i(i%e a &calar b" each element of a (ector or a matri# a& &ho'n belo'. BB SC01.8! SC 01 H ; BB SC018! III !rror using ??> %ldi$ide Matri+ di%ensions %ust agree. 6.5G66
3B Relational Aperators
The&e are the operator& 'here 'e can a&&ure of certain con%ition& tho&e are nece&&ar" for our %eci&ion ma$ing. The Boolean (or relational) operator& are &uch con%ition& tho&e are u&e% for %eci&ion/ma$ing. A po&iti(e number (u&uall" 0) repre&ent& T?UE an% 3ero repre&ent& =A!SE. =or e#ample./
0 JThe case is - because it is a true case. The table belo' %epict &uch occa&ion 'here it proof& the operation bet'een &uch ca&e&. +lea&e un%er&tan% that the #C0 &tan%& for the con%ition& 'hich can be true an% MC6 &tan%& 'here the con%ition& are fal&e.
21
Er.Soumen Chatterjee,B.Tech,M.S(USA)
9hen Matrice& are u&e% 'ith the relational operator&, the &i3e of the matrice& &houl% be the &ame. The compari&on i& ma%e on an element b" element ba&i&(an arra" operation) for matrice& an% (ector&. Con&i%er the follo'ing e#ample&. BB D0 1ECCD0 2E an& C 0 6
BB D0 1 2F2 G HEBD6 ; 2F0 2 5E Lcompari&on i& ba&e% upon element b" element an& C 0 6 6 0 0 6 Con(er&ion from ?ectangular to +olar an% +olar to ?ectangular YC1R2i BB 3C2R;iF BB rCab&(3) rC G BB thetaCangle(3) theta C 6.4152
Re&tan#ular to Polar
The relational operator& 'or$ e#cellent 'ith the character &tring %ata. @o'e(er, the matri# length or %imen&ion& mu&t agree BB UramanUCCU&amirU an& C 6 0 0 6 6
22
Er.Soumen Chatterjee,B.Tech,M.S(USA)
BB UchetanUCCU&oumenU an& C 6 6 6 6 6 0
Matri# %imen&ion &houl% agree 'ith no of character& are there in the 'or%& for both left an% right han% &i%e. An" mi&balance in that 'ill be pro(i%e% 'ith an error.
The&e compari&on& are u&eful in arranging the name& in alphabetical or%er, (erif"ing login an% pa&&'or% an% man" other &imilar purpo&e&.
A 6 6 0 0
A* 6 6 6 0
A]B
O? A`B 6 0 0 0
*OT _A 0 0 6 6
*OT_B 0 6 0 6
BB aCIBH ] UcUB UbU aC 0 BB uC1B2^(0R1i)J1 uC 0 The relation operator can al&o be applie% to (ector& or matrice& of e-ual %imen&ion& a& &ho'n in the e#ample belo'. BB A C D0 ; 4EF B C D1 1 GEF C C D6 G 1EF % C ABB ] ABC %C 2!
Er.Soumen Chatterjee,B.Tech,M.S(USA) 6 6 0
BB ABB an& C 6 0 0
BB ABC an& C 0 6 0
+ropertie& of Matri#
BB A C D2Te"e(1), 1Tone&(1)F 1Tone&(1), 2Te"e(1)E AC 2 6 1 1 6 2 1 1 1 1 2 6 1 1 6 2 Li& the pair of number& D m nE
( ) Trigonometric =unction& Sin1#, Co&H# or an" a& &uch trigonometric function& can be 'ritten a& BB &in(#)[1 an& C 6.56I0
2(
Er.Soumen Chatterjee,B.Tech,M.S(USA)
BB co&(#)[H an& C 6.61;4 &elp Facilities T"pe help to fin% a li&t of Matlab help topic& Shortcut& in Matlab comman% 'in%o'.
2)
'o%%and %eans
Autofi# M/!int Bac$. Brea$ !ine. Brea$ !ine 'ithout co%e e#ecution. Change to !o'er Ca&e. Change to Upper Ca&e. Clear Search. Clear Selection Clo&e Collap&e All Collpa&e Tree *o%e Collap&e or &elect Tree *o%e Comment Cop" Cur&or bac$'ar% Cur&or Begin ocument.
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Cur&or En% !ine Cur&or =or'ar% Cur&or ne#t 9or% Cur&or +re(iou& 'or% Cur&or Up Cut ecrea&e )ncrement Amount ecrea&e )n%ent ecrea&e Multiplication =actor 9rap Selecte% +ort& Up%ate +ort& Up%ate iagram&
2.
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Built in function for Arrays Some, of the built in function for arra"& a(ailable in Matlab are./
2/
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Description )f A i& a (ector, return& the mean (alue of the element&. )f A i& a (ector, C i& the large&t element in A.)f A i& a matri#,C i& a ro' (ector containing the large&t element of each column of A. )f A i& a (ector, return& the &um of the element& of the (ector )f A i& a (ector,return& the me%ian (alue of the element& of the (ector. )f A i& a (ector, return& the &tan%ar% %e(iation of the element& of the (ector ?eturn& the %eterminant of the &-uare matri# A. Calculate& the &calar (%ot) pro%uct of t'o (ector& a an% b. The (ector can each be ro' or column (ector&. Calculate& the cro&& pro%uct of t'o (ector& a an% b(a#b).The t'o (ector& mu&t ha(e 2 element&.
!+a%ple
BB ACD2 5 1 0HEF BB mean(A) an& C/
BB ACD2 5 1 0H 4 G 0I 02 6 ;EF BB CCma#(A) An&CI BB ACD2 5 1 0HEF BB &um(A) An&C1I BB ACD2 5 1 0HEF BB me%ian(A) An&CG BB ACD2 5 1 0HEF BB &t%(A) An&C6.H255 BB ACD0 1F2 ;EF BB %et(A) An&C/1 BB aCDG H 5EF BB bCD; 2 1EF BB %ot(a,b) an&CG1 BB aCDG H 5EF BB bCD; 2 1EF BB cro&&(a,b)
cross3a*b
)RABL!MS
!. "ind the magnitude of the ector A = #! $ % &'. &. "ind the magnitude of the ector A = #! + i $i % & &i'. %. (onsider the numbers !, &, %. )nter these as components of a column ector and as components of a row ector. *. +i en A , -!. &. %/. B , -*. 0. 1/. , fi nd the array product of the two ectors. 0. 2hat command would create a 0 0 matri3 with ones on the diagonal and 4eros e erywhere else5 1. (onsider the two matrices 6 $ !! &!& A = 1 07 ! B= 7 ! 1 * 8 & 76 &&& and compute their array product and matri3 product. $. 9uppose that A = !&% *01 $6: . ;se it to create B = 7 8 9 789 456 8."ind a solution to the following set of equations< x + &y + %z , !& *x + y + &z , !% :y 6z , ! 2hat is the determinant of the coefficient matri35 :. =oes a solution to the following system e3ist5 2hat is it5 20
x &y + %z , ! x + *y + %z , & &x + 6y + z , 3 !8. ;se L; decomposition to fi nd a solution to the system< x + $y :z , !& 2x y + *z , !1 x + y-$z , !1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
U&ing Matlab, %etermine the follo'ing. a) ARB. b) AB. c) A1. %) AT. e) B/0. f) BTAT. g) A1RB1/AB. h) %etA,%etB,or%etAB.
&elp in Matri+
!le%entary %ath functions an% their comman% t"pe or comman% meaning 21
Er.Soumen Chatterjee,B.Tech,M.S(USA) Trigonometric. &in / Sine. &in% / Sine of argument in %egree&. &inh / @"perbolic &ine. a&in / )n(er&e &ine. a&in% / )n(er&e &ine, re&ult in %egree&. a&inh / )n(er&e h"perbolic &ine. co& / Co&ine. co&% / Co&ine of argument in %egree&. co&h / @"perbolic co&ine. aco& / )n(er&e co&ine. aco&% / )n(er&e co&ine, re&ult in %egree&. aco&h / )n(er&e h"perbolic co&ine. tan / Tangent. tan% / Tangent of argument in %egree&. tanh / @"perbolic tangent. atan / )n(er&e tangent. atan% / )n(er&e tangent, re&ult in %egree&. atan1 / =our -ua%rant in(er&e tangent. atanh / )n(er&e h"perbolic tangent. &ec / Secant. &ec% / Secant of argument in %egree&. &ech / @"perbolic &ecant. a&ec / )n(er&e &ecant. a&ec% / )n(er&e &ecant, re&ult in %egree&. a&ech / )n(er&e h"perbolic &ecant. c&c / Co&ecant. c&c% / Co&ecant of argument in %egree&. c&ch / @"perbolic co&ecant. ac&c / )n(er&e co&ecant. ac&c% / )n(er&e co&ecant, re&ult in %egree&. ac&ch / )n(er&e h"perbolic co&ecant. cot / Cotangent. cot% / Cotangent of argument in %egree&. coth / @"perbolic cotangent. acot / )n(er&e cotangent. acot% / )n(er&e cotangent, re&ult in %egree&. acoth / )n(er&e h"perbolic cotangent. h"pot / S-uare root of &um of &-uare&. E#ponential. e#p / E#ponential. e#pm0 / Compute e#p(#)/0 accuratel". log / *atural logarithm. log0p / Compute log(0R#) accuratel". log06 / Common (ba&e 06) logarithm. log1 / Ba&e 1 logarithm an% %i&&ect floating point number. po'1 / Ba&e 1 po'er an% &cale floating point number. realpo' / +o'er that 'ill error out on comple# re&ult. reallog / *atural logarithm of real number. real&-rt / S-uare root of number greater than or e-ual to 3ero. &-rt / S-uare root. nthroot / ?eal n/th root of real number&. ne#tpo'1 / *e#t higher po'er of 1. Comple#. ab& / Ab&olute (alue. !2
Er.Soumen Chatterjee,B.Tech,M.S(USA) angle / +ha&e angle. comple# / Con&truct comple# %ata from real an% imaginar" part&. conj / Comple# conjugate. imag / Comple# imaginar" part. real / Comple# real part. un'rap / Un'rap pha&e angle. i&real / True for real arra". cpl#pair / Sort number& into comple# conjugate pair&. ?oun%ing an% remain%er. fi# / ?oun% to'ar%& 3ero. floor / ?oun% to'ar%& minu& infinit". ceil / ?oun% to'ar%& plu& infinit". roun% / ?oun% to'ar%& neare&t integer. mo% / Mo%ulu& (&igne% remain%er after %i(i&ion). rem / ?emain%er after %i(i&ion. &ign / Signum. !le%entary %atrices and %atri+ %anipulation. Elementar" matrice&. 3ero& / Yero& arra". one& / One& arra". e"e / )%entit" matri#. repmat / ?eplicate an% tile arra". lin&pace / !inearl" &pace% (ector. log&pace / !ogarithmicall" &pace% (ector. fre-&pace / =re-uenc" &pacing for fre-uenc" re&pon&e. me&hgri% / M an% N arra"& for 2/ plot&. accumarra" / Con&truct an arra" 'ith accumulation. . / ?egularl" &pace% (ector an% in%e# into matri#. Ba&ic arra" information. &i3e / Si3e of arra". length / !ength of (ector. n%im& / *umber of %imen&ion&. numel / *umber of element&. %i&p / i&pla" matri# or te#t. i&empt" / True for empt" arra". i&e-ual / True if arra"& are numericall" e-ual. i&e-ual'ithe-ualnan& / True if arra"& are numericall" e-ual. Matri# manipulation. cat / Concatenate arra"&. re&hape / ?e&hape arra". %iag / iagonal matrice& an% %iagonal& of matri#. bl$%iag / Bloc$ %iagonal concatenation. tril / E#tract lo'er triangular part. triu / E#tract upper triangular part. fliplr / =lip matri# in left8right %irection. flipu% / =lip matri# in up8%o'n %irection. flip%im / =lip matri# along &pecifie% %imen&ion. rot46 / ?otate matri# 46 %egree&. . / ?egularl" &pace% (ector an% in%e# into matri#. fin% / =in% in%ice& of non3ero element&. en% / !a&t in%e#. !1
Er.Soumen Chatterjee,B.Tech,M.S(USA) &ub1in% in%1&ub b&#fun / !inear in%e# from multiple &ub&cript&. / Multiple &ub&cript& from linear in%e#. / Binar" &ingleton e#pan&ion function.
Multi/%imen&ional arra" function&. n%gri% / Senerate arra"& for */ function& an% interpolation. permute / +ermute arra" %imen&ion&. ipermute / )n(er&e permute arra" %imen&ion&. &hift%im / Shift %imen&ion&. &-uee3e / ?emo(e &ingleton %imen&ion&. Arra" utilit" function&. i&&calar / True for &calar. i&(ector / True for (ector. Special (ariable& an% con&tant&. ep& / =loating point relati(e accurac". realma# / !arge&t po&iti(e floating point number. realmin / Smalle&t po&iti(e floating point number. intma# / !arge&t po&iti(e integer (alue. intmin / Smalle&t integer (alue. pi / 2.0;0G41HG2GI45.... i / )maginar" unit. inf / )nfinit". nan / *ot/a/*umber. i&nan / True for *ot/a/*umber. i&inf / True for infinite element&. i&finite / True for finite element&. j / )maginar" unit. 'h" / Succinct an&'er. Speciali3e% matrice&. compan / Companion matri#. galler" / Te&t matrice&. ha%amar% / @a%amar% matri#. han$el / @an$el matri#. hilb / @ilbert matri#. in(hilb / )n(er&e @ilbert matri#. magic / Magic &-uare. pa&cal / +a&cal matri#. ro&&er / Cla&&ic &"mmetric eigen(alue te&t problem. toeplit3 / Toeplit3 matri#. (an%er / Aan%ermon%e matri#. 'il$in&on / 9il$in&onU& eigen(alue te&t matri#.
Speciali3e% math function&. Speciali3e% math function&. air" / Air" function&. be&&elj / Be&&el function of the fir&t $in%. be&&el" / Be&&el function of the &econ% $in%. be&&elh / Be&&el function& of the thir% $in% (@an$el function). be&&eli / Mo%ifie% Be&&el function of the fir&t $in%. be&&el$ / Mo%ifie% Be&&el function of the &econ% $in%. beta / Beta function.
!2
Er.Soumen Chatterjee,B.Tech,M.S(USA)
betainc / )ncomplete beta function. betaincin( / )n(er&e incomplete beta function. betaln / !ogarithm of beta function. ellipj / 7acobi elliptic function&. ellip$e / Complete elliptic integral. erf / Error function. erfc / Complementar" error function. erfc# / Scale% complementar" error function. erfin( / )n(er&e error function. e#pint / E#ponential integral function. gamma / Samma function. gammainc / )ncomplete gamma function. gammaincin( / )n(er&e incomplete gamma function. gammaln / !ogarithm of gamma function. p&i / +&i (pol"gamma) function. legen%re / A&&ociate% !egen%re function. cro&& / Aector cro&& pro%uct. %ot / Aector %ot pro%uct. *umber theoretic function&. factor / +rime factor&. i&prime / True for prime number&. prime& / Senerate li&t of prime number&. gc% / Sreate&t common %i(i&or. lcm / !ea&t common multiple. rat / ?ational appro#imation. rat& / ?ational output. perm& / All po&&ible permutation&. nchoo&e$ / All combination& of * element& ta$en , at a time. factorial / =actorial function. Coor%inate tran&form&. cart1&ph / Tran&form Carte&ian to &pherical coor%inate&. cart1pol / Tran&form Carte&ian to polar coor%inate&. pol1cart / Tran&form polar to Carte&ian coor%inate&. &ph1cart / Tran&form &pherical to Carte&ian coor%inate&. h&(1rgb / Con(ert hue/&aturation/(alue color& to re%/green/blue. rgb1h&( / Con(ert re%/green/blue color& to hue/&aturation/(alue.
3B
+lot& are (er" u&eful tool for pre&enting information that inclu%e &tan%ar% plot& 'ith linear a#e&, plot& 'ith logarithmic an% &emi logarithmic a#e&, bar an% &tair& plot&, polar plot&, 2/ contour &urface an% me&h plot&, an% man" more. The plot& can be formatte% to ha(e a %e&ire% appearance. The line t"pe(&oli%, %a&he% etc.), colour an% thic$ne&& can be pre&cribe%, line mar$er& an% gri% line& can be a%%e%, a& 'ell a& title& an% te#t comment&. Se(eral graph& can be plotte% in the &ame plot an% &e(eral plot& can be place% on the &ame page.
!!
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Figure Toolbars The figure<& %efault toolbar pro(i%e& &hortcut& to commonl" u&e% feature&. The follo'ing picture &ho'& the feature& a(ailable from the toolbar./ )AK
Rotate !:" 5nsert Color4ar 5nsert 6e#end
7oom 5N8OU9
"ata Cursor
Hide8"isplay Plots
Sraphic& object& are the ba&ic element& u&e% to %i&pla" graph& an% u&er interface component&. The&e object& are organi3e% into a hierarch", a& &ho'n b" the follo'ing %iagram.
?oot
=igure !(
Er.Soumen Chatterjee,B.Tech,M.S(USA)
U) Object&
A#e&
Core Object&
+lot Object&
Sroup Object&
Annotating Object&
A good graph consists of properly labelled a+is that includes units* a descripti$e title and any rele$ant infor%ation about the plot.
Er.Soumen Chatterjee,B.Tech,M.S(USA) )t help& to plot the element& of (ector (or matri#) M on the hori3ontal a#i& of a figure, an% the element& of (ector (or matri#) N on the (ertical a#i& of the figure. 0) BB MCD0 1 2 G 5 5.G I 06EF BB NCD1 H.G 5 5 G.G ; H IEF BB plot(M,N)
2)
ra' a plot of "Cco&(#) 'ith an inter(al of 6J#J06. Ta$e the (alue& of # for %ifferent (alue& &uch a& 0,6.0an% 6.60 a) =or #C6.0 A& the (alue& of #C6.0 the graph& 'ill be &harper from the a#i& a& the 6.0 'ill &"nthe&i3e the (alue& for "Cco&(#). BB #C6.6.0.06F BB "Cco&(#)F BB plot(#,")
!.
Er.Soumen Chatterjee,B.Tech,M.S(USA)
C!= 'ill clear the figure at the figure 'in%o'. =or 1/ +lot& the ba&ic comman% i& plot(#,"). A linear e-uation i& of the form of a#Rb"Cc, 'here a a 6 an% b a 6. )t& graph i& a &traight line an% a& alrea%" mentione%, onl" t'o point& or or%ere% pair& are re-uire%. )f an e-uation i& not linear, then the (ariable& # an% " are rai&e% to at lea&t the &econ% po'er, an% the &hape of the graph i& &ome &ort of cur(e. The # a#i& i& the hori3ontal a#i& on the Carte&ian plane an% i& referee% a& the ab&ci&&a. The " a#i& i& the (ertical a#i& on the Carte&ian plane an% i& referre% a& the or%inate.
Aector&
Specifier& that %efine The t"pe an% color of the !ine an% mar$er&.
+ropertie& 'ith (alue& that can be u&e% to &pecif" the line 'i%th, an% Mar$er<& &i3e an% e%ge, an% fill color
!ine &pecifier& !ine &t"le Soli%(%efault) a&he% otte% a&h/%ot !ine Color &pecifier& are./ !ine Color ?e% Sreen Blue C"an Magneta Nello' Blac$ Mar$er T"pe &pecifier&./ &pecifier bbbb /////////
=
/././. Specifier r g B C M N $
!/
Er.Soumen Chatterjee,B.Tech,M.S(USA) Mar$er t"pe +lu& &ign Circle A&teri&$ +oint S-uare iamon% =i(e pointe &tar Si# point &tar Specifier / o
5
. s d p h
The &pecifier& are t"pe% in&i%e the plot comman% a& &tring&. 9ithin the &tring the &pecifier& can be t"pe% in an" or%er. The &pecifier& are optional. Thi& mean& that none, one ,t'o, or all the three can be inclu%e% in a comman%. The comman% can be 'ritten a& for e#ample plot(#,",<r<) +ropert" *ame )roperty Ka%e line'i%th mar$er&i3e mar$ere%gecolor Mar$erfacecolor Description Specifie& the 'i%th of the line Specifie& the &i3e of the mar$er Specifie& the color of the mar$er, or the color of the e%ge line for fille% mar$er&. Specifie& the color of the filling for fille% mar$er& )ossible )roperty "alues A number in unit& of point&(%efault 6.G) A number in unit& of point&. Color &pecifie& from the table abo(e, t"pe% a& a &tring. Color &pecifie& from the table abo(e t"pe%, a& a &tring.
eg the belo' comman% loo$& li$e +lot(#,",</mo<,<!ine'i%th<,1,<mar$er&i3e<,01,<mar$ere%gecolor<,<g<,<mar$erfacecolor<,<"<) A note about line &pecifie& an% propertie&. The three line &pecifier&, 'hich are the &t"le an% color of the line,an% the t"pe of the mar$er can al&o be a&&igne% 'ith a propertyna%e argument follo'e% b" a property$alue argument. Specifier !ine &t"le !ine color Mar$er )roperty Ka%e !ine&t"le Color Mar$er )ossible )roperty "alues !ine &t"le &pecifier from the table abo(e,t"pe% a& a &tring. Color &pecifier& from the table& abo(e, t"pe% a& a &tring. Mar$er &pecifier from the table abo(e,t"pe% a& a &tring.
+lot of a gi(en %ata Near Sale& 04II I 04I4 01 0446 16 0440 11 0441 0I 0442 1; 044; 15
Property name and property 'alue;t$e line widt$ is 2 points and t$e markers si%e is 12 point<
!0
Er.Soumen Chatterjee,B.Tech,M.S(USA)
i&tortion of an" plot V;) +lot comman% "C2.G/6.G# co&(H#) for /1c#c;. U&ing the (alue of # a& 6.60 an% 6.2 0) 9hen #C6.60 BB #CD/1.6.60.;EF BB "C2.G.[(/6.GT#).Tco&(HT#)F BB plot(#,") BB title(Ugraph of &ignal 'hen #C6.60U) BB #label(U# a#i&U) BB "label(U" a#i&U)
1) 9hen #C6.2 BB #CD/1.6.2.;EF BB "C2.G.[(/6.GT#).Tco&(HT#)F BB plot(#,") BB #label(U# a#i&U) BB "label(U" a#i&U) BB title(Ugraph of &ignal 'hen #C6.2U)
!1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
VG) Senerate an o(erla" plot for plotting three line& y-?sint*y0?t*y2?t4t272,/t676,/t;7;, :U tU 0V BB tClin&pace(6,1Tpi,066)F BB "0C&in(t)F BB "1CtF BB "2Ct/(t.[2)8HR(t.[G)8016/(t.[5)8G6;6F BB plot(t,"0,t,"1,U/U,t,"2,UoU) BB a#i&(D6 G /0 GE) BB #label(UtU) BB "label(U&in(t) appro#imationU) BB title(U&in(t) functionU) BB te#t(2.G,6, U&in(t)U) BB gte#t(U!inear appro#imationU) BB gte#t(U;/term appro#imationU)
VH)U&ing the follo'ing function& to plot the gi(en %ata./ 0) r1CG co& 2tF 6 c t c1Q BB tClin&pace(6,1Tpi,166)F BB rC&-rt(ab&(GTco&(2Tt)))F BB polar(t,r,<d$T<)
(2
Er.Soumen Chatterjee,B.Tech,M.S(USA)
V4)Senerate a plot of "(#)Ce/6.5# &ine# , 'here C0Gra%8& an% 6c # c0G BB #CD6.6.0.0GEF BB 'C0GF BB "Ce#p(/6.5T#).T&in('T#)F BB plot(#,") BB title(U"(#)Ce[/[6[.[5[#&inZomega) BB #label(UtU) BB title(U"(#)Ce[/[6[.[5[#&inZomega#U) BB #label(U#U) BB "label(U"U)
(1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Contour +lot&./ )f 'e ha(e t'o (ariable& # an% " are embe%%e% into &ame e-uation an% the an&'er can be foun% out into thir% (ariable irre&pecti(e of range. Then 'e can fin% the &olution u&ing contour plot&. V06) 9rite an e-uation if 3C#1R"1 'ith a range from /2 c#c 2 an% /2 c"c 2. BB D#,"ECme&hgri%(/2.6.0.2,/2.6.0.2)F BB contour(#,",#.[1R".[1) BB a#i& &-uare Here t$e ran#e of = and y BB #label(U# a#i&U) are same w$i&$ 'aries from BB "label(U" a#i&U) :! to !< 9$us> we needed to BB title(UContour +lot& of # an% " u&ing me&hgir% comman%U) use mes$#rid &ommand
V00) 9rite an e-uation for circle of ra%ii for (alue& of 0,G H for the e-uation. 3C#1R"1 BB contour(#,",#.[1R".[1,D0 1 2E) BB a#i& &-uare BB #label(U# a#i&U) BB "label(U" a#i&U) BB title(UContour +lot& of # an% " 'ithout u&ing me&hgir% comman%U)
(2
Er.Soumen Chatterjee,B.Tech,M.S(USA)
&old on and &old off co%%ands To plot &e(eral graph& u&ing the hol% on,hol% off comman%&, one graph i& plotte% fir&t 'ith the plot comman%. Then the hold on comman% i& t"pe%. Thi& $eep& the figure 'in%o' 'ith the fir&t plot open, inclu%ing the a#i& propertie& an% formatting. A%%itional graph& can be a%%e% 'ith the plot comman%& that are t"pe% ne#t. Each plot comman% create& a graph that i& a%%e% to that figure. The hold off comman% &top& thi& proce&&. )t return& the Matlab into %efault mo%e in 'hich the plot comman% era&e& the pre(iou& plot an% re&et& the a#i& propertie&. V01) +lot the graph of the function "C2#2/1H#R06 an% it<& fir&t an% &econ% %eri(ati(e& 'here the (alue& range from /1 c# c;. BB #CD/1.6.60.;EF BB "C2T#.[2/1HT#R06F BB "%C4T#.[1/1HF BB "%%C0IT#F BB plot(#,",U/bU) BB hol% on BB plot(#,"%,U//rU) BB hol% on BB plot(#,"%%,U.$U) BB hol% off BB #label(U(alue& /1 to ;U) BB "label(U"%UU"%%UU"U) BB title(Ua graph repre&enting hol% on an off comman%&U)
Er.Soumen Chatterjee,B.Tech,M.S(USA) T'o or more graph& can be create% in the &ame plot b" t"ping pair& of (ector& in&i%e the plot comman%.)t i& al&o po&&ible to a%% line &pecifier& follo'ing each pair. =or e#ample the comman%.
BB "rCD04II.044;EF BB &leCDI 01 16 11 0I 1; 15EF BB bar("r,&le,U$U) BB #label(U"earU) BB "label(U&ale& per "earU) BB title(Ubar graph bet'een &ale& an% "earU)
((
Er.Soumen Chatterjee,B.Tech,M.S(USA)
b) Bar graph in hori3ontal BB "rCD04II.044;EF BB &leCDI 01 16 11 0I 1; 15EF BB barh("r,&le,U$U) BB #label(U&ale& per "earU) BB "label(U"earU) BB title(Ubar graph in hori3ontal bet'een &ale& an% "earU)
c) Stair& BB "rCD04II.044;EF BB &leCDI 01 16 11 0I 1; 15EF BB &tair&("r,&le,UrU) BB #label(U&ale& per "earU) BB "label(U"earU) BB title(Ubar graph in hori3ontal bet'een &ale& an% "earU)
()
Er.Soumen Chatterjee,B.Tech,M.S(USA)
%) Stem +lot . BB "rCD04II.044;EF BB &leCDI 01 16 11 0I 1; 15EF BB &tem("r,&le,UmU) BB #label(U"earU) BB "label(U&ale& per "earU) BB title(UStem +lot can be u&e for Sampling fre-uenc" al&oU)
&istogra%s (.
Er.Soumen Chatterjee,B.Tech,M.S(USA) The&e are the &tati&tical plot& that &ho' the %i&tribution of the %ata.The o(erall range of a gi(en &et of %ata point& i& %i(i%e% into &maller &ubrange&, an% the hi&togram &ho'& ho' man" %ata point& are in each bin. )t i& a (ertical bar plot in 'hich the 'i%th of each bar i& e-ual to the range of the corre&pon%ing bin. U&e point& hi&t(") a& the comman% 'here "Ci& a (ector 'ith the %ata point&.Matlab %i(i%e& the range of the %ata
BB "CDGI 52 52 G2 G6 ;I GH 52 52 HH H4 H2 5; I1 I; 40 42 I4 40 I6 G4 H4 GH H; H2 HH H; 5; H2 H4EF BB hi&t(") BB #label(U(alue& of "earU) BB "label(Uhi&togramU) BB title(U@i&togram plot of %ifferent "ear &ale& reportU)
)f 'e 'ant to &ee ho' man" element& are in each bin.Simple u&e. nChi&t(") for e#ample BB nChi&t(") nC 1 2 1 5 2 H 6 2 6 ;
)olar )lots +olar coor%inate& in 'hich the po&ition of a point in a plane i& %efine% b" the angle theta an% the ra%iu& to the point, are fre-uentl" u&e% in the &olution of &cience an% engineering problem&.The polar comman%& i& u&e% to plot function& in polar coor%inate&. The comman% ha& the term. polar ? t$eta> radius > -line spe&ifiers- A
"ector
"ector
Specifiers that define the type and color of the Line and %arkers
9here theta,ra%iu& are (ector& 'ho&e element& %efine the coor%inate& of the point& to be plotte%.The polar comman% plot& the point an% %ra'& the gri%. V0;) +lot a function rC2 co&1(6.Gf )R f for all (alue& 6c f c 1 Q BB tClin&pace(6,1Tpi,166)F (/
Sub )lots Multiple plot& on the &ame page can be create% 'ith the &ubplot comman% 'hich ha& the form. 9here, m time& n in%epen%ent &ub'in%o'&, 'here m an% n in%icate that the acti(e figure 'in%o' i& %i(i%e% into m time& n in%epen%ent matri# li$e &ub'in%o'& an% p i& an integer o(er the range. su4plot?m>n>pA
=or e#ample if there i& a &ubplot of (1,1,2) in%icate& that the figure 'in%o' i& %i(i%e% into four &ub'in%o'& (t'o ro'& b" t'o column&) an% the current plot &ub'in%o' i& the thir%(&econ% ro' b" fir&t column). V0H) ra' the &ubplot for (ariou& e-uation&
BB "C/1.6.0.1F BB #C4T".[2/1HT".[1R15F BB &ubplot(2,1,0) BB plot(#,",U//$TU) BB #C4T".[1R15T"F BB &ubplot(2,1,1) BB plot(#,",U//$TU) BB #C4T"F BB &ubplot(2,1,2) BB plot(#,",U//$TU) BB #C0IT".[1R1GT"F BB &ubplot(2,1,;) BB plot(#,",U//$TU) BB #C0IT".[2F BB &ubplot(2,1,G) BB plot(#,",U//$TU) BB #C0IT"F BB &ubplot(2,1,H) BB plot(#,",U//$TU)
(0
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Lograthi%ic Graphs The main rea&on for u&ing lograthimic &cale& i& to repre&ent %ata that &prea%& o(er a 'i%e range. V05) ra' the &emilog #, &emilog " an% loglog for the (ariou& (alue& of # an% " a& the e-uation precee%& NC1 6.1#R06 'here # range& from 6.0 c# c0666 BB #Clin&pace(6.0,H6,0666)F BB "C1.[(/6.1T#R06)F BB &emilog"(#,",<d$T<) BB gri% on
9$is is a semilo#y w$ere t$e fun&tion f?=A+k?aA4= Bnd if t$e = a=is is linear and y a=is is lo#rat$imi&>t$e plot f?=A '8s = is linear<
(1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
9$is is a semilo#= returns t$e plot of y '8s = w$ere t$e = a=is s&ale is lo#art$imi& 4ut t$e y a=is is linear<
9$e Matla4 &ommand lo#lo#?=>yA returns t$e plot of y '8s = w$ere 4ot$ t$e a=es s&ales are lo#rat$imi&<
)f a figure alrea%" e#i&t&, the plot comman% automaticall" clear& the e#i&ting figure an% create& a ne' one.The comman% clf clear& the acti(e figure 'in%o'. The plot comman% 'ith multiple argument& can be u&e% to create multiple plot& on the &ame graph& for eg.plot(#,"0,#,"1,#,"2.....#,"n) pro(i%e% their %imen&ion& &houl% be &ame. )f no color or line &t"le i& &pecifie%, the %efault i& & &oli% blue or blac$ line. Mar$er& are u&e% to in%icate point& or %i&crete entrie&. )f no mar$er t"pe i& &electe%, no mar$er& are %ra'n. The comman% color%ef %efine the o(erall color compo&ition of the figure 'in%o'. The %efault i& color%ef 'hite or color%ef none. )f a %ifferent color compo&ition an% bac$groun% i& re-uire% then u&e the comman% color%ef color an% &pecif" the color accor%ing to option& a(ailable.
)2
Er.Soumen Chatterjee,B.Tech,M.S(USA) Two di%ensional graphs. Elementar" M/N graph&. plot / !inear plot. loglog / !og/log &cale plot. &emilog# / Semi/log &cale plot. &emilog" / Semi/log &cale plot. polar / +olar coor%inate plot. plot"" / Sraph& 'ith " tic$ label& on the left an% right. A#i& control. a#i& / 3oom / gri% / bo# / rbbo# / hol% / a#e& / &ubplot / Control a#i& &caling an% appearance. Yoom in an% out on a 1/ plot. Sri% line&. A#i& bo#. ?ubberban% bo#. @ol% current graph. Create a#e& in arbitrar" po&ition&. Create a#e& in tile% po&ition&.
Sraph annotation. plote%it / Tool& for e%iting an% annotating plot&. title / Sraph title. #label / M/a#i& label. "label / N/a#i& label. te#label / +ro%uce& the TeM format from a character &tring. te#t / Te#t annotation. gte#t / +lace te#t 'ith mou&e. @ar%cop" an% printing. print / +rint graph or Simulin$ &"&temF or &a(e graph to M/file. printopt / +rinter %efault&. orient / Set paper orientation. SpecialiGed 04D Graphs Speciali3e% 1/ graph&. area / =ille% area plot. bar / Bar graph. barh / @ori3ontal bar graph. comet / Comet/li$e trajector". compa&& / Compa&& plot. errorbar / Error bar plot. e3plot / Ea&" to u&e function plotter. e3polar / Ea&" to u&e polar coor%inate plotter. feather / =eather plot. fill / =ille% 1/ pol"gon&. fplot / +lot function. hi&t / @i&togram. pareto / +areto chart. pie / +ie chart. plotmatri# / Scatter plot matri#. ro&e / Angle hi&togram plot. &catter / Scatter plot. &tem / i&crete &e-uence or :&tem: plot. &tair& / Stair&tep plot. )1
Er.Soumen Chatterjee,B.Tech,M.S(USA) Contour an% 1/081 graph&. contour / Contour plot. contourf / =ille% contour plot. contour2 / 2/ Contour plot. clabel / Contour plot ele(ation label&. e3contour / Ea&" to u&e contour plotter. e3contourf / Ea&" to u&e fille% contour plotter. pcolor / +&eu%ocolor (chec$erboar%) plot. (oronoi / Aoronoi %iagram. Speciali3e% 2/ bar2 / bar2h / comet2 / e3graph2 / e3me&h / e3me&hc / e3plot2 / e3&urf / e3&urfc / me&hc / me&h3 / pie2 / ribbon / &catter2 / &tem2 / &urfc / tri&urf / trime&h / 'aterfall / graph&. 2/ bar graph. @ori3ontal 2/ bar graph. 2/ comet/li$e trajectorie&. Seneral purpo&e &urface plotter. Ea&" to u&e 2/ me&h plotter. Ea&" to u&e combination me&h8contour plotter. Ea&" to u&e 2/ parametric cur(e plotter. Ea&" to u&e 2/ colore% &urface plotter. Ea&" to u&e combination &urf8contour plotter. Combination me&h8contour plot. 2/ me&h 'ith curtain. 2/ pie chart. ra' 1/ line& a& ribbon& in 2/ . 2/ &catter plot. 2/ &tem plot. Combination &urf8contour plot. Triangular &urface plot. Triangular me&h plot. 9aterfall plot.
Aolume an% (ector (i&uali3ation. (i&&uite / Ai&uali3ation &uite. i&o&urface / )&o&urface e#tractor. i&onormal& / )&o&urface normal&. i&ocap& / )&o&urface en% cap&. i&ocolor& / )&o&urface an% patch color&. contour&lice / Contour& in &lice plane&. &lice / Aolumetric &lice plot. &treamline / Streamline& from 1 or 2 (ector %ata. &tream2 / 2 &treamline&. &tream1 / 1 &treamline&. -ui(er2 / 2 -ui(er plot. -ui(er / 1 -ui(er plot. %i(ergence / i(ergence of a (ector fiel%. curl / Curl an% angular (elocit" of a (ector fiel%. coneplot / 2 cone plot. &treamtube / 2 &tream tube. &treamribbon / 2 &tream ribbon. &tream&lice / Streamline& in &lice plane&. &treamparticle& / i&pla" &tream particle&. interp&tream&pee% / )nterpolate &treamline (ertice& from &pee%. &ub(olume / E#tract &ub&et of (olume %ata&et. re%uce(olume / ?e%uce (olume %ata&et. (olumeboun%& / ?eturn& #,",3 an% color limit& for (olume %ata. &mooth2 / Smooth 2 %ata. )2
Er.Soumen Chatterjee,B.Tech,M.S(USA) re%ucepatch / ?e%uce number of patch face&. &hrin$face& / ?e%uce &i3e of patch face&. )mage& %i&pla" an% file )8O. image / i&pla" image. image&c / Scale %ata an% %i&pla" a& image. colormap / Color loo$/up table. gra" / !inear gra"/&cale color map. contra&t / Sra" &cale color map to enhance image contra&t. brighten / Brighten or %ar$en color map. colorbar / i&pla" color bar (color &cale). imrea% / ?ea% image from graphic& file. im'rite / 9rite image to graphic& file. imfinfo / )nformation about graphic& file. im1ja(a / Con(ert image to 7a(a image. Mo(ie& an% animation. getframe / Set mo(ie frame. mo(ie / +la" recor%e% mo(ie frame&. rotate / ?otate object about &pecifie% origin an% %irection. frame1im / Con(ert mo(ie frame to in%e#e% image. im1frame / Con(ert in%e# image into mo(ie format. Color relate% function&. &pinmap / Spin color map. rgbplot / +lot color map. col&t"le / +ar&e color an% &t"le from &tring. in%1rgb / Con(ert in%e#e% image to ?SB image. rgb1in% / Con(ert ?SB image to in%e#e% image. %ither / Con(ert image u&ing %ithering. Soli% mo%eling. c"lin%er / Senerate c"lin%er. &phere / Senerate &phere. ellip&oi% / Senerate ellip&oi%. patch / Create patch. &urf1patch / Con(ert &urface %ata to patch %ata. Type help specgraph
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Line )lot
2/ !ine plot i& a line that i& obtaine% b" connecting point& in a 2/ imen&ional place. A ba&ic 2/ be create% 'ith the help of plot2 comman%. line plot can
Specifier& that %efine the t"pe an% color of the line an% mar$er&.
+ropertie& that can be u&e% to &pecif The line 'i%th an% mar$er &i3e.
The three (ector& 'ith the coor%inate& of the %ata point& mu&t ha(e the &ame number of element&. The line &pecifier&,propertie& an% propert" (alue& are the &ame a& in 1/ plot&.
V0) =or the three coor%inate& MCg t &in(1t) NCgt co&(1t) YC6.G t =or plot of point& for 6c tc H BB tC6.6.0.HTpiF BB #C&-rt(t).T&in(1Tt)F BB "C&-rt(t).Tco&(1Tt)F BB 3C6.GTtF BB plot2(#,",3,U//T$U) BB gri% on BB #label(U#U)F BB "label(U"U)F BB 3label(U3U)F
9e can al&o 'rite plot2 in thi& fa&hion .. BB tC/1.6.60.1F BB plot2(co&(1TpiTt),&in(1TpiTt),t,U//T$U) BB #label(U#U) BB "label(U"U) BB 3label(U3U) BB Title(Uthree (ariable u&ing three %ifferent e-uation&U)
)(
Er.Soumen Chatterjee,B.Tech,M.S(USA)
V16) ra' the plot comman% for &int,co&t an% t it&elf for %ifferent (alue& of t BB tClin&pace(6,06Tpi)F BB plot2(&in(t),co&(t),t,U//,TU) BB #label(U#U) BB "label(U"U) BB 3label(U3U) BB Title(U@eli#U) BB gri% on
BB tC6.pi8066.1TpiF BB #C&in(t)F BB "C&in(t/6.21)F BB 3C&in(1Tt)F BB plot2(#,",3) BB plot2(#,",3,U//T$U) BB #label(U#U) BB "label(U"U) BB 3label(U3U) BB title(Ua &imple graph of #," an% 3 a#i&U) BB gri% on
))
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Mesh and Surface )lots Matlab %efine& a me&h &urface b" the 3/coor%inate& of point& abo(e a rectangular gri% in the #/" plane. )t form& a plot b" joining a%jacent point& 'ith &traight line&. The re&ult& loo$& li$e it a fi&hing net 'ith the $not& at the %ata point&. BB #C/0.2F BB "C0.;F BB D#,"ECme&hgri%(#,") #C /0 /0 /0 /0 6 6 6 6 0 0 0 0 1 1 1 1 2 2 2 2
).
Er.Soumen Chatterjee,B.Tech,M.S(USA)
"C 0 1 2 ; 0 1 2 ; 0 1 2 ; 0 1 2 ; 0 1 2 ;
BB me&h(#,")
That i& "ou %on<t ha(e to t"pe gri% on at the en% of each &tatement. So,
D M,NECme&hgri%(#,")
Therefore there are t'o comman%& that are u&e% for me&h or &urf plot& are %esh3S*T*W surf3S*T*W
A me&h or &urface plot i& create% 'ith the me&h or &urf comman%&, 'hich ha(e the form&. 'here M,N are matrice& 'ith the coor%inate& of the gri% an% Y i& a matri# 'ith the (alue of 3 at the gri% point&. The me&h plot i& ma%e of line& that connect the point&. The &urf plot, area& 'ithin the me&h line& are colore%. V10)BB DM,NECme&hgri%(/1Tpi.6.0.1Tpi,/1Tpi.6.0.1Tpi)F BB YCco&(M).T&in(N)F BB me&h(M,N,Y) BB#label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) )/
BB DM,NECme&hgri%(/1Tpi.6.0.1Tpi,/1Tpi.6.0.1Tpi)F BB YCco&(M).T&in(N)F BB me&h(M,N,Y) BB &urf(M,N,Y) BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(USurf graph or plotU)
V11) BB DM,NECme&hgri%(/1.6.0.1)F BB YCN.Te#p(/M.[1/N.[1)F BB me&h(M,N,Y) BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(UMe&h +lot& for e-uation&U)
)0
Er.Soumen Chatterjee,B.Tech,M.S(USA)
BB DM,NECme&hgri%(/1.6.0.1)F BB YCN.Te#p(/#.[1/".[1)F BB &urf(M,N,Y) BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(USurf +lot& for e-uation&U)
=or abo(e e-uation& 'e can plot the function& u&ing a &ha%e% &urface plot.Thi& i& %one b" u&ing &urf or &urfc.The colour& u&e% are proportional to the &urface height& at a gi(en point. =or the moment 'e can u&e &urfl//////////// remember l i& a &mall W!< not )////We"e<. )t gi(e& the appearance of a three/%imen&ional illuminate% object. U&e thi& option if"ou 'oul% li$e a three/%imen&ional plot 'ithout the me&h line& &ho'n in the other figure&. V12) BB DM,NECme&hgri%(/1.6.0.1)F BB YCN.Te#p(/M.[1/N.[1)F BB &urfl(M,N,Y) BB &ha%ing )nterp BB color mapgra"F BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(U)lluminate% Surf +lot& for e-uation&U) )1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
!et u& generate a u&eful c"lin%er u&ing &urf comman%.'here 'e can u&e the function a& ./ V1;) 0R&in(t) for the (alue& of 6 ctc 1Q BB tC6.pi806.1TpiF BB DM,N,YECc"lin%er(0R&in(t))F BB &urf(M,N,Y) BB a#i& &-uare BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(U&urf comman% for a c"lin%erU)
Here we are usin# t$e &ommand s$adin# fa&eted>t$us we are $a'in# different fis$net type of #rap$
.2
Er.Soumen Chatterjee,B.Tech,M.S(USA)
Here we are usin# t$e &ommand s$adin# interp >t$us we are $a'in# different a #ood #rap$<
V1G) BB #C/0.6.0.2F BB "C0.6.0.;F BB DM,NECme&hgri%(#,")F BB YCM.TN.[1.8(M.[1RN.[1)F BB me&h(M,N,Y) BB #label(U#U)F BB "label(U"U)F BB 3label(U3U)F BB title(Ume&h groupU)
BB "C0.6.0.;F BB YCM.TN.[1.8(M.[1RN.[1)F BB &urf(M,N,Y) BB #label(U#U)F BB "label(U"U)F BB 3label(U3U)F BB title(Ume&h groupU) BB title(U&urf plot& for matlabU)
.1
Er.Soumen Chatterjee,B.Tech,M.S(USA)
The plot& that are create% ha(e colour& that (ar" accor%ing to the magnitu%e of 3. The (ariation in colour a%%& to the three/%imen&ional (i&uali3ation of the plot&. The color can be change% to be con&tant either b" u&ing the plot e%itor or b" u&ing colormap(C) comman%. C i& a three element (ector in 'hich the fir&t, &econ% an% thir% element& &pecif" the inten&it" of ?e%,Sreen an% Blue (?SB) color& re&pecti(el". CCD6 6 6E blac$ CCD0 6 0Emagneta CCD0 6 6E re% CCD606E green CCD6.G 6.G 6.GEgre". CCD6 6 0Eblue CCD0 0 6E"ello'
9hen the me&t comman% e#ecute&, the gir% i& on b" %efault. The gri% can be off b" comman% gri% off. A bo# can be %ra'n aroun% the plot 'ith the bo# on comman%. V1H) ra' the (ariou& e#ample& for 3C0.I /0.Gg #1R"1 &in(#)co&(6.G") o(er the %omain of /2 c# c2 ] /2 c"c 2.
BB #C/2.6.1G.2F BB "C/2.6.1G.2F BB DM,NECme&hgri%(#,")F BB YC0.I.[(/0.GT&-rt(M.[1RN.[1)).Tco&(6.GTN).T&in(M)F BB contour2(M,N,Y,0G) BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(UContour plot& for #, " an% 3U)
)lot a Sphere .2
Er.Soumen Chatterjee,B.Tech,M.S(USA) )t return& the #,", an% 3 coor%inate& of a unit &phere 'ith 16 face&. BB DM,N,YEC&phere(16)F BB &urf(M,N,Y)
)lot a 2D Bar Graph =or an" (alue& of N 'e can ha(e a bar graph 'ith bar2 a& it<& a&&et. BB NCD0 H.G 5F1 H 5F2 G.G 5F; G 5F2 ; 5F1 2 5F0 1 5EF BB bar2(N)
.!
Er.Soumen Chatterjee,B.Tech,M.S(USA)
24D Ste% )lot BB tC6.6.1.06F #CtF "C&in(t)F 3Ct.[0.GF &tem2(#,",3,UfillU) gri% on #label(U# a#i&U) "label(U" a#i&U) 3label(U3 a#i&U)
Er.Soumen Chatterjee,B.Tech,M.S(USA) The (ie' comman% control& the %irection from 'hich the plot i& (ie'e%. Thi& i& %one b" &pecif"ing a %irection in term& of a3imuth an% ele(ation angle& or b" %efining a point in &pace from 'hich the plot i& (ie'e%. To &et the (ie'ing angle of the plot, the (ie' comman% ha& the form. Ciew?a%>elA or 'iew?@a%>elDA G y eye ele$ation aGi%uth +
aG i& the a3imuth, 'hich i& an angle (in %egree&) in the #/" plane mea&ure% relati(e to the negati(e " a#i& %irection an% %efine% a& po&iti(e in the countercloc$'i&e %irection. el i& the angle of ele(ation( in %egree&) from the #/" plane. A po&iti(e (alue corre&pon%& to opening an angle in the %irection of the 3/a#i&. The %efault (ie' angle& are a3C/25.G %egree& an% elC26 %egree&. V15) =or 3C0.I /0.Gg #1R"1 &in(#)co&(6.G") o(er the %omain of /2c # c2 ] /2 c" c2. BB #C/2.6.1G.2F BB"C/2.6.1G.2F BBDM,NECme&hgri%(#,")F BBYC0.I.[(/0.GT&-rt(M.[1RN.[1)).Tco&(6.GTN).T&in(M)F BB&urf(M,N,Y) BB (ie'(16,2G) BB #label(U# a#i&U) BB "label(U" a#i&U) BB 3label(U3 a#i&U) BB title(Ua3imuth projection of the angle&U)
B" choo&ing appropriate a3imuth an% ele(ation angle& the (ie' comman% can be u&e% to plot projection& of 2/ plot& on (ariou& plane& accor%ing to the follo'ing table.
.)
Er.Soumen Chatterjee,B.Tech,M.S(USA)
+rojection +lane #/"(top (ie') #/3(&i%e (ie') "/3(&i%e (ie') a3 (alue 6 6 46 el (alue 46 6 6
As we will take e+a%ple for three different proRection plane for the eFuations as=4
BB #C/2.6.1G.2F ..
Three di%ensional graphs. Elementar" 2/ plot&. plot2 / +lot line& an% point& in 2/ me&h / 2/ me&h &urface. &urf / 2/ colore% &urface. fill2 / =ille% 2/ pol"gon&. Color control. colormap ca#i& &ha%ing hi%%en brighten color%ef gra"mon cmpermute cmuni-ue imappro# !ighting. &urfl lighting material &pecular %iffu&e &urfnorm Color map&. h&( hot gra" bone copper &pace.
/ Color loo$/up table. / +&eu%ocolor a#i& &caling. / Color &ha%ing mo%e. / Me&h hi%%en line remo(al mo%e. / Brighten or %ar$en color map. / Set color %efault&. / Set graphic& %efault& for gra"/&cale monitor&. / ?earrange color& in colormap. / Eliminate unnee%e% color& in colormap of in%e#e% image. / Appro#imate in%e#e% image b" one 'ith fe'er color&.
/ 2/ &ha%e% &urface 'ith lighting. / !ighting mo%e. / Material reflectance mo%e. / Specular reflectance. / iffu&e reflectance. / Surface normal&. / @ue/&aturation/(alue color map. / Blac$/re%/"ello'/'hite color map. / !inear gra"/&cale color map. / Sra"/&cale 'ith tinge of blue color map. / !inear copper/tone color map. ./
Er.Soumen Chatterjee,B.Tech,M.S(USA) pin$ 'hite flag line& colorcube (ga jet pri&m cool autumn &pring 'inter &ummer / +a&tel &ha%e& of pin$ color map. / All 'hite color map. / Alternating re%, 'hite, blue, an% blac$ color map. / Color map 'ith the line color&. / Enhance% color/cube color map. / 9in%o'& colormap for 0H color&. / Aariant of @SA. / +ri&m color map. / Sha%e& of c"an an% magenta color map. / Sha%e& of re% an% "ello' color map. / Sha%e& of magenta an% "ello' color map. / Sha%e& of blue an% green color map. / Sha%e& of green an% "ello' color map.
Tran&parenc". alpha / Tran&parenc" (alpha) mo%e. alphamap / Tran&parenc" (alpha) loo$/up table. alim / Tran&parenc" (alpha) &caling A#i& control. a#i& / Control a#i& &caling an% appearance. 3oom / Yoom in an% out on a 1/ plot. gri% / Sri% line&. bo# / A#i& bo#. hol% / @ol% current graph. a#e& / Create a#e& in arbitrar" po&ition&. &ubplot / Create a#e& in tile% po&ition&. %a&pect / ata a&pect ratio. pba&pect / +lot bo# a&pect ratio. #lim / M limit&. "lim / N limit&. 3lim / Y limit&. Aie'point control. (ie' / 2/ graph (ie'point &pecification. (ie'mt# / Aie' tran&formation matri#. rotate2% / )nteracti(el" rotate (ie' of 2/ plot. Camera control. campo& camtarget cam(a camup camproj / Camera po&ition. / Camera target. / Camera (ie' angle. / Camera up (ector. / Camera projection.
@igh le(el camera control. camorbit / Orbit camera. campan / +an camera. cam%oll" / oll" camera. cam3oom / Yoom camera. camroll / ?oll camera. camloo$at / Mo(e camera an% target to (ie' &pecifie% object&. cameratoolbar / )nteracti(el" manipulate camera. @igh le(el light control. camlight / Create& or &et& po&ition of a light. lightangle / Spherical po&ition of a light. .0
Er.Soumen Chatterjee,B.Tech,M.S(USA) Sraph annotation. title / Sraph title. #label / M/a#i& label. "label / N/a#i& label. 3label / Y/a#i& label. te#t / Te#t annotation. gte#t / Mou&e placement of te#t. plote%it / E#perimental graph e%iting an% annotation tool&. @ar%cop" an% printing. print / +rint graph or Simulin$ &"&temF or &a(e graph to M/file. printopt / +rinter %efault&. orient / Set paper orientation. (rml / Sa(e graphic& to A?M! 1.6 file.
.1