




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
PlottinginMatlab
Page
PAGE
1
BasicsofPlottinginMatlabGSF3/22/12
TableofContents
BasicOverview
Syntax
LabelingAxes
Legends
ManipulatingAxes
Subplots
MultipleY-Axes
Statistics
3-Dplots
AdditionalResources
BasicOverview
Tousethe‘plot’functioninMatlab,youshouldfirstmakesurethatthematrices/vectorsyouaretryingtouseareofequaldimensions.Forexample,ifIwantedtoplotvectorX=[3927]overtime,myvectorfortimewouldalsoneedtobea1x3vector(i.e.t=[123]).
Syntax
Toplottheexamplevectorsaboveinanewfigure:
clearall %clearallpreviousvariables
X=[3927];%mydependentvectorofinterestt=[123]; %myindependentvector
figure %createnewfigureplot(t,X)
LabelingAxes
Togivetheabovefigureatitleandaxislabels:
title(‘PlotofDistanceoverTime’) %titleylabel(‘Distance(m)’) %labelforyaxisxlabel(‘Time(s)’) %labelforxaxis
Legends
Ifyouhaveplottedmultipledependentvectorsonthesameplotandwanttodistinguishthemfromeachotherviaalegend,thesyntaxisverysimilartotheaxislabelingabove.Itisalsopossibletosetcolorsforthedifferentvectorsandtochangethelocationofthelegendonthefigure.
Example:
clearall
X=[3927]; %dependentvectorsofinterest
Y=[1086];
Z=[444];
t=[123]; %independentvectorfigure
holdon %allowallvectorstobeplottedinsame
%figure
plot(t,X,‘blue’,t,Y,‘red’,t,Z,‘green’)
title(‘PlotofDistanceoverTime’) %titleylabel(‘Distance(m)’) %labelforyaxisxlabel(‘Time(s)’) %labelforxaxis
legend(‘Trial1’,‘Trial2’,‘Trial3’)legend(‘Location’,‘NorthWest’)%movelegendtoupperleft
Subplots
Itcansometimesbeusefultodisplaymultipleplotsonthesamefigureforcomparison.Thiscanbedoneusingthesubplotfunction,thattakesargumentsfornumberofrowsofplots,numberofcolumnsofplots,andplotnumbercurrentlybeingplotted:
Example:
clearallcloseall
%subplot(nrows,ncols,plot_number)
x=0:.1:2*pi; %xvectorfrom0to2*pi,dx=0.1
subplot(2,2,1); %plotsinefunctionplot(x,sin(x));
subplot(2,2,2); %plotcosinefunctionplot(x,cos(x));
subplot(2,2,3) %plotnegativeexponentialfunctionplot(x,exp(-x));
subplot(2,2,4); %plotx^3plot(x,x.^3);
Plottingin3-D
TherearealsowaystoplotinmultipledimensionsinMatlab*.Onetypeof3-Dplotthatmaybeusefulisasurfaceplot,whichrequiresyoutogeneratesomekindofx-yplaneandthenapplya3rdfunctionasthezdimension.
Example:
clearallcloseall
[x,y]=meshgrid([-2:.2:2]); %setup2-Dplane
Z=x.*exp(-x.^2-y.^2); %plot3rddimensiononplane
figure
surf(x,y,Z,gradient(Z)) %surfaceplot,withgradient(Z)
%determiningcolordistribution
colorbar %displaycolorscale,canadjust
%locationsimilarlytolegend
Seereferencematerialforamoredetaileddescriptionof3-Dplottinganditsapplications.
AdditionalMatlabReferences
InMatlab,type‘help(insertphrase)’togetdescriptionofcommandfunctionality
Ex.helpplot givesinstructionsforwhatargumentstopasstheplotfunction,howtouseit,whatoutputtoexpect,etc.
Matlabwebsite:
/help/techdoc/
Usef
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 幼兒園心理輔導(dǎo)工作的探索計劃
- 提升市場競爭力的行動方案計劃
- 2025年氣體摻混設(shè)備項目合作計劃書
- 2025年太陽能電池生產(chǎn)專用設(shè)備合作協(xié)議書
- 2025年CRO服務(wù)項目發(fā)展計劃
- 2025年儲冷、蓄熱裝置項目合作計劃書
- 2025年奧硝唑藥物項目發(fā)展計劃
- 2025年轉(zhuǎn)基因抗蟲樹木新品種合作協(xié)議書
- 智能交通系統(tǒng)建設(shè)運(yùn)營合同
- 工程咨詢與設(shè)計服務(wù)框架協(xié)議
- 2025年度產(chǎn)業(yè)園區(qū)建設(shè)項目委托代建服務(wù)協(xié)議
- 鄉(xiāng)鎮(zhèn)機(jī)關(guān)考勤管理制度
- 四年級語文下冊第六單元【集體備課】(教材解讀+教學(xué)設(shè)計)
- (完整版)園藝產(chǎn)品貯藏與加工
- 京東考試答案
- 《對折剪紙》)ppt
- 各種系列產(chǎn)品質(zhì)量指標(biāo)詳述
- 以虛報注冊資本、虛假出資、抽逃出資為由對實行認(rèn)繳資本登記制的公司進(jìn)行處罰無法律依據(jù)
- 感染性休克PPT課件
- 風(fēng)電場生產(chǎn)運(yùn)營準(zhǔn)備大綱11.14
- 人教版八年級語文下冊教材研說
評論
0/150
提交評論