Danh mục

Lecture note Data visualization - Chapter 23

Số trang: 51      Loại file: pptx      Dung lượng: 4.14 MB      Lượt xem: 14      Lượt tải: 0    
10.10.2023

Hỗ trợ phí lưu trữ khi tải xuống: 22,000 VND Tải xuống file đầy đủ (51 trang) 0
Xem trước 6 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

This chapter presents the following content: Chapter 5 “plotting”, two dimensional plots, simple x-y plots, titles, labels and grids, multiple plots, plots with more than one line, plots of complex arrays, line, color and mark style, axis scaling and annotating plots,...
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 23Lecture23RecapChapter5“Plotting”TwoDimensionalPlotsSimplexyPlotsTitles,LabelsandGridsMultiplePlotsPlotswithMorethanOneLineAplotwithmorethanonelinecanbecreatedinseveral waysBydefault,theexecutionofasecondplotstatementwill erasethefirstplotHowever,youcanlayerplotsontopofoneanotherby usingtheholdoncommandExecutethefollowingstatementstocreateaplotwith bothfunctionsplottedonthesamegraph x=0:pi/100:2*pi; y1=cos(x*4); plot(x,y1)TheholdoncommandcanbeusedtolayerplotsonsamegraphContinued….Semicolonsareoptionalonboththeplotstatementand theholdonstatementMATLABwillcontinuetolayertheplotsuntilthehold offcommandisexecuted: holdoffAnotherwaytocreateagraphwithmultiplelinesisto requestbothlinesinasingleplotcommandMATLABinterpretstheinputtoplotasalternatingxand yvectors,asin plot(X1,Y1,X2,Y2)Continued….Iftheplotfunctioniscalledwithasinglematrix argument,MATLABdrawsaseparatelineforeach columnofthematrixThexaxisislabeledwiththerowindexvector,1:k, wherekisthenumberofrowsinthematrix.This producesanevenlyspacedplot,sometimescalledaline plotIfplotiscalledwithtwoarguments,oneavectorandthe otheramatrix,MATLABsuccessivelyplotsalinefor eachrowinthematrixForexample:wecancombiney1andy2intoasingleContinued….Here’sanothermorecomplicatedexample: X=0:pi/100:2*pi; Y1=cos(X)*2; Y2=cos(X)*3; Y3=cos(X)*4; Y4=cos(X)*5; Z=[Y1;Y2;Y3;Y4]; plot(X,Y1,X,Y2,X,Y3,X,Y4)ThiscodeproducesthesameresultasMultiplePlotsonSameGraphContinued….Afunctionoftwovariables,thepeaksfunctionproduces sampledatathatareusefulfordemonstratingcertain graphingfunctionsCallingpeakswithasingleargumentnwillcreateannxn matrixWecanusepeakstodemonstratethepowerofusinga matrixargumentintheplotfunctionThecommand plot(peaks(100))resultsintheimpressivegraphThepeakFunction,plottedwithsingleaugmentinplotCommandPlotsofComplexArraysIftheinputtotheplotcommandisasinglearrayof complexnumbers,MATLABplotstherealcomponenton thexaxisandtheimaginarycomponentontheyaxisForexample:if A=[0+0i,1+2i,2+5i,3+4i]then plot(A) title(PlotofaSingleComplexArray) xlabel(RealComponent)Continued….Ifweattempttousetwoarraysofcomplexnumbersinthe plotfunction,theimaginarycomponentsareignoredTherealportionofthefirstarrayisusedforthexvalues, andtherealportionofthesecondarrayisusedforthey– valuesToillustrate,firstcreateanotherarraycalledBbytaking thesineofthecomplexarrayA: B=sin(A)returns B=03.1658+1.9596i67.478930.8794i3.853727.0168iLine,ColorandMarkStyleTheappearanceofplotscanbechangedbyselectinguser definedlinestylesandlinecolorsandbychoosingto showthedatapointsonthegraphwithuserspecified markstylesThecommand helpplotreturnsalistoftheavailableoptionsContinued….Thefollowingcommandsillustratetheuseofline,color, andmarkstyles: x=[1:10]; y=[58.5,63.8,64.2,67.3,71.5,88.3,90.1,90.6, 89.5,90.4]; plot(x,y,:ok)Theresultingplot(showninnextslide)consistsofa dashedline,togetherwithdatapointsmarkedwithcirclesContinued….Tospecifyline,mark,andcolorstylesformultiplelines, addastringcontainingthechoicesaftereachpairofdata pointsIfthestringisnotincluded,thedefaultsareusedForexample: plot(x,y,:ok,x,y*2,xr,x,y/2,b)resultsinthegraphshowninnextslide

Tài liệu được xem nhiều: