Matlab 分享兴趣,传播快乐,增长见闻,留下美好。 亲爱的您, 这里是LearingYard学苑! 今天小编为大家带来matlab二维绘图 欢迎您的用心访问! 本期推文阅读时长大约5分钟,请您耐心阅读。 Shareinterest,spreadhappiness,increaseknowledge,andleavebeautiful。 Dearyou, ThisistheLearingYardAcademy! Today,theeditorbringsyoumatlabtwodimensionaldrawing Welcomeyourvisit! Thistweetusuallytakesabout5minutestoread,pleasereaditpatiently。 1本期主题介绍 Thetopicofthisissue 如果您了解过Matlab, 您肯定知道Matlab不只是计算! Matlab还有一个强大的绘图功能! 本期话题将对matlab的二维图进行介绍。 请感兴趣的朋友和小编开启 学习Matlab的二维绘图之旅吧! IfyouknowMatlab, YoumustknowthatMatlabismorethanjustcomputing! Matlabalsohasapowerfuldrawingfunction! Thetopicofthisissuewillintroducethetwodimensionalmapofmatlab。 Pleaseopenitwithinterestedfriendsandeditors LearnthejourneyoftwodimensionaldrawinginMatlab! 2Matlab二维绘图 Matlabtwodimensionaldrawing 1。绘制二维曲线 Drawatwodimensionalcurve plot函数的基本调用格式为:plot(x,y) 其中x和y为长度相同的向量,分别用于存储x坐标和y坐标数据;当x是实向量时,plot(x)以该向量元素的下标为横坐标,元素值为纵坐标画出一条折线图,当x为矩阵时,plot(x)以列为向量画出几条折线(矩阵列数);当x,y是同维矩阵时,则以x,y对应列元素为横、纵坐标分别绘制曲线,曲线条数等于矩阵的列数。 Thebasiccallingformatoftheplotfunctionis:plot(x,y) Wherexandyarevectorsofthesamelength,whichareusedtostorexcoordinateandycoordinatedatarespectively;whenxisarealvector,plot(x)usesthesubscriptofthevectorelementastheabscissa,andtheelementvalueistheordinatetodrawApolylinegraph,whenxisamatrix,plot(x)drawsseveralpolylines(thenumberofmatrixcolumns)withcolumnsasvectors;whenxandyarematrixesofthesamedimension,thecorrespondingcolumnelementsofxandyarehorizontalandDrawcurvesontheordinate,andthenumberofcurvesisequaltothenumberofcolumnsinthematrix 3Matlab二维绘图实际操作 Matlabtwodimensionaldrawingactualoperation 1。plot绘单条曲线图 plotdrawasinglecurvegraph x0:0。01pi:2pi; ysin(x); plot(x,y) 2。plot绘制多条曲线图 plotplotsmultiplecurves 格式为:plot(x,y1,x2,y2,。。。。。。,xn,yn) Theformatis:plot(x,y1,x2,y2,。。。。。。,xn,yn) 以向量对的形式绘制曲线。 Drawcurvesintheformofvectorpairs。 x0:0。01pi:2pi; y1sin(x); y2sin(x0。25pi); y3sin(x0。5pi); plot(x,y1,x,y2,x,y3) plot(x,y1,。b,x,y2,r,x,y3,。gh) b代表的是蓝色,r为红色,gh为绿色 brepresentsblue,risred,ghisgreen 3。holdon与holdoff的应用 Applicationofholdonandholdoff 如果绘制一个曲线后,想要保持当前曲线不变,在当前曲线基础上绘制新的曲线,这时我们可以采用holdon,关闭时可以用holdoff。 Ifyouwanttokeepthecurrentcurveunchangedafterdrawingacurve,anddrawanewcurvebasedonthecurrentcurve,wecanuseholdonatthistime,anduseholdoffwhenclosing。 x0:0。1:1; yx; plot(x,y) holdon x1:0。1:2; y0。5x。40。5; plot(x,y) holdon x2:0。1:5; yx。29x5。5; plot(x,y) holdoff 4。绘制特殊的二维曲线,比如只想要描述点,而不想要线 Drawaspecialtwodimensionalcurve,suchasonlywantingtodescribepoints,butnotlines x0:pi15:4pi; yexp(2cos(x)); plot(x,y,r) 5。绘制对数曲线 Drawalogarithmiccurve xlinspace(1,100,100); yexp(x); loglog(x,y) 这样就绘制了双对数曲线 Thisdrawsadoublelogarithmiccurve xlinspace(1,100,100); yexp(x); semilogy(x,y) Y为对数坐标轴 Yisthelogarithmicaxis xlinspace(1,100,100); yexp(x); semilogx(x,y) x为对数坐标轴 xisthelogarithmicaxis 6。fplot函数的应用 flot函数的基本用法:fplot(f,lims,参数) f代表一个函数,通常采用函数句柄的形式。lims为x轴的取值范围,默认值为〔5,5〕。参数与plot函数相同。 Applicationoffplotfunction Thebasicusageofflotfunction:fplot(f,lims,parameter) frepresentsafunction,usuallyintheformofafunctionhandle。limsisthevaluerangeofthexaxis,andthedefaultvalueis〔5,5〕。Theparametersarethesameastheplotfunction。 xt(t)cos(3t); yt(t)sin(2t); fplot(xt,yt) fplot双输入函数的基本用法:fplot(funx,funy,tlims,参数) funx、funy代表函数,通常采用函数句柄的形式,tlims为参数函数funx和funy得到自变量取值范围。 fplot((t)t。sin(t),(t)t。cos(t)) Thebasicusageoffplotdualinputfunction:fplot(funx,funy,tlims,parameter) funxandfunyrepresentfunctions,usuallyintheformofafunctionhandle,tlimsistheparameterfunctionfunxandfunytogetthevaluerangeoftheindependentvariable。 fplot((t)t。sin(t),(t)t。cos(t)) 7。polarplot函数的应用 Applicationof。polarplotfunction t0:0。1pi:4pi; aabs(sin(2t)。cos(2t)); polarplot(t,a,b) 8。绘制图形的辅助操作 给图形添加标注 title(图形标题) title(图形标题,Color,r,FontSize,24) xlable(x轴说明) ylable(y轴说明) text(x,y,图形说明) legend(图例) xlinspace(0,2pi,100); y1sin(x); y2sin(2x); plot(x,sin(x),x,sin(2x)) legend(sin(x),sin(3x),sin(2x)) 9。坐标轴 Coordinateaxiscontrol控制 axis〔xmin,xmax,ymin,ymax,zmin,zmax〕 axisequal:纵横坐标轴次采用等长刻度 axissquare:产生正方形坐标系(默认为矩形) axisauto:使用默认设置 axisoff:不显示坐标轴 axison:显示坐标轴 给坐标轴加网格 gridon gridoff grid 给坐标系加边框 boxon bixoff box 图形保存 holdon holdoff hold xlinspace(0,2pi,100); tlinspace(0,2pi,100); xsin(t); ycos(t); plot(x,y,b) holdon; plot(2x,2y,r); gridon axis(〔2。2,2。2,2。2,2。2〕) axisequal 今天的分享就到这里了。 如果您对今天的文章有独特的想法, 欢迎给我们留言, 让我们相约明天, 祝您今天过得开心快乐! Thatsitfortodayssharing。 Ifyouhaveauniqueideaabouttoday’sarticle, Welcometoleaveusamessage, Letusmeettomorrow, Iwishyouahappydaytoday! End 参考资料:Google翻译、哔哩哔哩 本文由LearningYard学苑整理并发出,如有侵权请在后台留言! LearningYard学苑 文案Qian 排版Qian 审核Tian