机械振动加州大学University of CaliforniaChapter5TwoD要点.docx

上传人:b****8 文档编号:13193451 上传时间:2023-06-11 格式:DOCX 页数:20 大小:167.12KB
下载 相关 举报
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第1页
第1页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第2页
第2页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第3页
第3页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第4页
第4页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第5页
第5页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第6页
第6页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第7页
第7页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第8页
第8页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第9页
第9页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第10页
第10页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第11页
第11页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第12页
第12页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第13页
第13页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第14页
第14页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第15页
第15页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第16页
第16页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第17页
第17页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第18页
第18页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第19页
第19页 / 共20页
机械振动加州大学University of CaliforniaChapter5TwoD要点.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

机械振动加州大学University of CaliforniaChapter5TwoD要点.docx

《机械振动加州大学University of CaliforniaChapter5TwoD要点.docx》由会员分享,可在线阅读,更多相关《机械振动加州大学University of CaliforniaChapter5TwoD要点.docx(20页珍藏版)》请在冰点文库上搜索。

机械振动加州大学University of CaliforniaChapter5TwoD要点.docx

机械振动加州大学UniversityofCaliforniaChapter5TwoD要点

Chapter5Two-DimensionalPlots

5.1THEPLOTCOMMAND

∙Tocreatetwo-dimensionalplots

plot(x,y)

-Theargumentsxandyareeachavector(one-dimensionalarray).

-Bothvectorsmusthavethesamenumberofelements.

-WhentheplotcommandisexecutedafigureiscreatedintheFigureWindow.

-Thecurveisconstructedofstraight-linesegmentsthatconnectthepointswhosecoordinatesaredefinedbytheelementofthevectorsxandy.

-Thefigurethatiscreatedhasaxeswithlinearscaleanddefaultrange.

-Forexample,

>>x=[123577.5810];

>>y=[26.5775.5468];

>>plot(x,y)

-Theplotappearsonthescreeninbluewhichisthedefaultlinecolor.

∙Theplotcommandhasadditionaloptionalargumentsthatcanbeusedtospecifythecolorandstyleofthelineandthecolorandtypeofmarkers,ifanyaredesired.Withtheseoptionsthecommandhastheform:

plot(x,y,’linespecifiers’,’PropertyName’,

PropertyValue)

-(Optional)‘linespecifiers’thatdefinesthetypeandcolorofthelineandmarkers.

-(Optional)With’PropertyName’,PropertyValue,propertieswithvaluesthatcanbeusedtospecifythelinewidth,andmarker’ssizeandedge,andfillcolors.

LineSpecifiers:

∙Thelinestylespecifiersare:

LineStyle

Specifier

LineStyle

Specifier

Solid(default)

-

Dotted

:

Dashed

--

Dash-dot

-.

∙Thelinecolorspecifiersare:

LineColor

Specifier

LineColor

Specifier

Red

r

Magenta

m

Green

g

Yellow

y

Blue

b

Black

k

Cyan

c

White

w

∙Themarkertypespecifiersare:

MarkerType

Specifier

MarkerType

Specifier

plussign

+

square

s

circle

o

diamond

d

asterisk

*

five-pointedstar

p

point

.

six-pointedstar

h

Notesaboutusingthespecifiers

∙Thespecifiersaretypedinsidetheplotcommandasstrings.

∙Withinthestringthespecifierscanbetypedinanyorder.

∙Thespecifiersareoptional.Thismeansthatnone,one,two,orallthethreecanbeincludedinacommand.

∙Someexamples:

plot(x,y,’r’)Aredsolidlineconnectsthepoints.

plot(x,y,’--y’)Ayellowdashedlineconnectsthepoints.

plot(x,y,’*’)Thepointsaremarkedwith*(nolinebetweenthepoints).

plot(x,y,’g:

d’)Agreendottedlineconnectsthepointsthataremarkedwithdiamondmarkers.

 

PropertyNameandPropertyValue:

∙Propertiesareoptionalandcanbeusedtospecifythethicknessoftheline,thesizeofthemarker,andthecolorsofthemarker’sedgelineandfill.

∙ThePropertyNameistypedasastring,followedbyacommandavaluefortheproperty,allinsidetheplotcommand.

∙Fourpropertiesandpossiblevaluesare:

PropertyName

Description

PossiblePropertyValues

LineWidth

(orlinewidth)

Specifiesthewidthoftheline

Anumberinunitsofpoints(default0.5)

MarkerSize

(ormarkersize)

Specifiesthesizeofthemarker

Anumberinunitsofpoints

MarkerEdgeColor

(ormarkeredgecolor)

Specifiesthecolorofthemarker,orthecoloroftheedgelineforfilledmarker.

Colorspecifiers,typedasastring

MarkerFaceColor

(ormarkerfacecolor)

Specifiesthecolorofthefillingforfilledmarker

Colorspecifiers,typedasastring

-Forexample,thecommandscreateaplotthatconnectsthepointswithamagentasolidlineandcirclesasmarkersatthepoints.Thelinewidthistwopointsandthesizeofthecirclemarkersis12points.Themarkershaveagreenedgelineandyellowfilling.

>>x=[123577.5810];

>>y=[26.5775.5468];

>>plot(x,y,'-mo','linewidth',2,'markersize',12,'markeredgecolor','g','markerfacecolor','y')

5.1.1PlotofGivenData

∙Forexample,withthesalesdataofacompanyfrom1988to1994,

>>yr=[1988:

1:

1994];

>>sle=[8122022182427];

>>plot(yr,sle,'--r*','linewidth',2,'markersize',12)

5.1.2PlotofaFunction

∙Toplotagivenfunction,usetheplotorthefplotcommands.

∙Withtheplotcommand,theuserneedstofirstcreateavectorofvaluesofxforthedomainthatthefunctionwillbeplotted.Then,avectoryiscreatedbyusingelement-by-elementcalculations.

∙Toplot

for-2x4,

%Chapter5Plot1.m

%thefunction:

3.5.^(-0.5*x).*cos(6x)

x=[-2:

0.01:

4];

y=3.5.^(-0.5*x).*cos(6*x);

plot(x,y)

>>helpChapter5Plot1

Chapter5Plot1.m

thefunction:

3.5.^(-0.5*x).*cos(6x)

>>Chapter5Plot1

-TheplotcanbecopiedfromtheFigureWindow(intheEditmenuselectCopyFigure)andthenpasteitinotherapplications.

5.2THEfplotCOMMAND

∙Thefplotcommandplotsafunctionwiththeformy=f(x)betweenspecifiedlimits.Thecommandhastheform:

fplot(‘function’,limits,linespecifiers)

‘function’

-Thefunctioncanbetypeddirectlyastringinsidethecommand.Forexample,ifthefunctionis

itistypedas‘8*x^2+5*cos(x)’.

-Thefunctioncannotincludepreviouslydefinedvariables.

limits

-Thelimitsisavectorwithtwoelementsthatspecifythedomainofx[xmin,xmax],oravectorwithfourelementsthatspecifiesthedomainofxandthelimitsofthey-axis[xmin,xmax,ymin,ymax].

∙Forexample,aplotof

for

canbecreatedwiththefplotcommand:

>>fplot('x^2+4*sin(2*x)-1',[-33])

5.3PLOTTINGMULTIPLEGRAPHSINTHESAMEPLOT

5.3.1UsingtheplotCommand

∙Twoormoregraphscanbecreatedinthesameplotbytypingpairsofvectorsinsidetheplotcommand:

plot(x,y,u,v,t,h)

-Itcreatesthreegraphsallinthesameplot.

-Thevectorsofeachpairmustbeofthesamelength.

-MATLABautomaticallyplotsthegraphsindifferentcolors.

-Itispossibletoaddlinespecifiersfollowingeachpair.Forexample,

plot(x,y,’-b’,u,v,’—r’,t,h,’g:

’)

[SampleProblem5-1]Plotthefunction

anditsfirstandsecondderivatives,for-2x4,allinthesameplot.

%SP5_1.m

x=[-2:

0.01:

4];

y=3*x.^3-26*x+10;

dy=9*x.^2-26;

ddy=18*x;

plot(x,y,'-b',x,dy,'--r',x,ddy,':

k')

 

5.3.2Usingtheholdon,holdoffCommands

%SP5_1_a.mforSampleProblem5-1

x=[-2:

0.01:

4];

y=3*x.^3-26*x+10;

dy=9*x.^2-26;

ddy=18*x;

plot(x,y,'-b')

holdon

plot(x,dy,'--r')

plot(x,ddy,':

k')

 

5.3.3UsingthelineCommand

∙Withthelinecommandadditionalgraphs(lines)canbeaddedtoaplotthatalreadyexists.Theformofthelinecommandis:

line(x,y,’PropertyName’,propertyValue)

-(Optional)’PropertyName’,propertyValue

-Theformatoflinecommandisalmostthesameastheplotcommand.

-Thelinecommanddoesnothavethelinespecifiers.

Theplotcommandstartsanewploteverytimeitisexecuted,whilethelinecommandaddslinestoaplotthatalreadyexists.Thus,fortheSampleProblem5-1,thefollowingM-filecanbeused:

%SP5_1_b.mforSampleProblem5-1

x=[-2:

0.01:

4];

y=3*x.^3-26*x+10;

dy=9*x.^2-26;

ddy=18*x;

plot(x,y,'-b')

line(x,dy,'linestyle','--','color','r')

line(x,ddy,'linestyle',':

','color','k')

 

5.4FORMATTINGAPLOT

∙Afigurethatcontainsaplotneedstobeformattedtodisplayinformationinadditiontothegraphitself.Itcanincludespecifyingaxislabels,plottitle,legend,grid,rangeofcustomaxis,andtextlabels.

5.4.1FormattingaplotUsingCommands

Thexlabelandylabelcommands:

∙Labelscanbeplacednexttotheaxeswiththefollowingcommands:

xlabel(‘textasstring’)

ylabel(‘textasstring’)

Thetitlecommand:

∙Thetextisplacedatthetopofthefigureasatitlewiththefollowingcommand:

title(‘textasstring’)

Thetextcommand:

∙Atextcanbeplacedintheplotwiththetextorgtextcommands:

text(x,y,’textasstring’)

gtext(‘textasstring’)

-Thetextcommandplacesthetextinthefiguresuchthatthefirstcharacterispositionedatthepointwiththecoordinatesx,y(accordingtotheaxesofthefigure).

-Thegtextcommandplacesthetextatapositionspecifiedbytheuser.Whenthecommandisexecuted,theFigureWindowopensandtheuserspecifiesthepositionwiththemouse.

Thelegendcommand:

∙Toplacealegendontheplot,

legend(‘string1’,‘string2’,…,pos)

-Thestringsarethelabelsthatareplacednexttothelinesample.

-Theirordercorrespondstotheorderthatthegraphswerecreated.

-Theposisanoptionalnumberthatspecifieswhereinthefigurethelegendisplaced.Theoptionsare:

pos=-1Placesthelegendoutsidetheaxesboundariesontherightside.

pos=0Placesthelegendinsidetheaxesboundariesinalocationthatinterferestheleastwiththegraphs.

pos=1Placesthelegendattheupper-rightcorneroftheplot(default).

pos=2Placesthelegendattheupper-leftcorneroftheplot.

pos=3Placesthelegendatthelower-leftcorneroftheplot.

pos=4Placesthelegendatthelower-rightcorneroftheplot.

Formattingthetext:

∙AcompleteexplanationofalltheformattingfeaturescanbefoundintheHelpWindowunderTextandTextProperties.

∙Theformattingcanbedoneeitherbyaddingmodifiersinsidethestring,orbyaddingtothecommandoptionalPropertyNameandPropertyValueargumentsfollowingthestring.

∙Themodifiersarecharactersthatareinsertedwithinthestring.

Modifier

Effect

\bf

boldfont

\it

italicstyle

\rm

normalfont

\fontname{fontname}

specifiesfontisused

\fontsize{fontsize}

specifiesfontsizeisused

-Thesemodifiersaffectthetextfromthepointthattheyareinserteduntiltheendofthestring.

-Itispossibletohavethemodifiersappliedtoonlyasectionofthestringbytypingthemodifierandthetexttobeaffectedinsidebraces{}.

∙Thesubscriptandsuperscript:

-Asinglecharactercanbedisplayedasasubscriptorasuperscriptbytyping_or^infrontofthecharacter,respectively.

-Severalconsecutivecharacterscanbedisplayedassubscriptorasuperscriptbytypingthecharactersinsidebraces{}followingthe_orthe^.

 

∙Greekcharac

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2