机械振动加州大学University of CaliforniaChapter5TwoDimensionalPlotsWord格式文档下载.docx
- 文档编号:22341067
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:20
- 大小:167.10KB
机械振动加州大学University of CaliforniaChapter5TwoDimensionalPlotsWord格式文档下载.docx
《机械振动加州大学University of CaliforniaChapter5TwoDimensionalPlotsWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《机械振动加州大学University of CaliforniaChapter5TwoDimensionalPlotsWord格式文档下载.docx(20页珍藏版)》请在冰豆网上搜索。
Specifier
Solid(default)
-
Dotted
:
Dashed
--
Dash-dot
-.
∙Thelinecolorspecifiersare:
LineColor
Red
r
Magenta
m
Green
g
Yellow
y
Blue
b
Black
k
Cyan
c
White
w
∙Themarkertypespecifiersare:
MarkerType
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
-Forexample,thecommandscreateaplotthatconnectsthepointswithamagentasolidlineandcirclesasmarkersatthepoints.Thelinewidthistwopointsandthesizeofthecirclemarkersis12points.Themarkershaveagreenedgelineandyellowfilling.
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*'
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);
helpChapter5Plot1
Chapter5Plot1.m
thefunction:
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
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
holdon
plot(x,dy,'
plot(x,ddy,'
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
line(x,dy,'
linestyle'
--'
color'
r'
line(x,ddy,'
'
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^.
∙
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 机械振动加州大学University of CaliforniaChapter5TwoDimensionalPlots 机械振动 加州大学 University
链接地址:https://www.bdocx.com/doc/22341067.html