吴言乱语MATLAB基础学习之二维绘图
分享兴趣,传播快乐,
增长见闻,留下美好。
亲爱的您,
这里是LearingYard学苑!
今天小编为大家带来matlab二维绘图
欢迎您的用心访问!
本期推文阅读时长大约5分钟,请您耐心阅读。
Share interest, spread happiness, increase knowledge, and leave beautiful.
Dear you,
This is the LearingYard Academy!
Today, the editor brings you matlab two-dimensional drawing
Welcome your visit!
This tweet usually takes about 5 minutes to read, please read it patiently.
01.本期主题介绍
Topic introduction of this issu
在我们研究问题的过程中,对于模型结果分析,很多时候都需要运用图表来帮助我们去观察数据与数据之间的联系。这时候我们就可以充分利用MATLAB强大的绘图功能,来帮助我们解决问题。
那么,今天就跟随小编一起学习如何使用MATLAB的二维绘图吧!
In the process of our research, for the analysis of model results, we often need to use charts to help us observe the relationship between data and data. At this time, we can make full use of the powerful drawing function of MATLAB to help us solve problems.
So, let"s learn how to use the two-dimensional drawing of MATLAB with Xiaobian today!
02.创建二维单线图
Create 2D single line diagram
(1) plot(x,y) 用于绘制二维图形。
首先我们定义x为[0,10]的向量,然后将y创建为x的一次线性函数值。
Plot (x, y) is used to draw two-dimensional graphics.
First, we define x as a vector of [0,10], and then create y as the linear function value of X.
(2)stairs(x,y)阶梯线条形状二维图形。
依旧定义x为[0,10]的向量,然后将y创建为x的一次线性函数值。
Stairs (x, y) ladder line shape is two-dimensional.
Still define x as a vector of [0,10], and then create y as the linear function value of X.
(3)指定二维图线条形状。
依据前面所创建的函数,只需要在plot函数中指定形状即可,如:plot(x,y,"*")。
Specifies the 2D line shape.
According to the previously created function, you only need to specify the shape in the plot function, such as plot (x, y, "*").
(4)改变二维图形线条颜色。
要更改线条颜色可在plot( x,y )对组中添加线条设定输入参数。例如,"g" 将绘制绿色直线。
Change the line color of 2D graphics.
To change the line color, add lines to the group in plot (x, y) and set input parameters. For example, "g" will draw a green line.
我们也可以同时指定线条形状和颜色,如"r:*" ,将绘制星标号的绿色点线。
We can also specify the line shape and color at the same time, such as" r: * ", which will draw the green dotted line with Star label.
03.绘制二维多线图
Draw 2D multiline graph
绘制多个线条的二维图形方法与单线条类似。下面依旧用举例的方式进行解释。
The method of drawing two-dimensional graphics of multiple lines is similar to that of a single line. The following is still explained by way of example.
(1) 绘制多线条二维图形。
首先我们定义x为[0,10]的向量,并将y1和y2定义为两条平行的直线。
Draw multi line 2D graphics.
First, we define x as a vector of [0,10], and define Y1 and Y2 as two parallel lines.
x=0:10
y1=3+4*x
y2=6+4*x
plot(x,y1,x,y2)
(2)指定线型和颜色。
依旧定义x为[0,10]的向量,并将y1和y2定义为两条平行的直线。如"r--"表示颜色为红色的"--"线条形状,我们也可以只改变颜色或只改变形状,直接表示为"r"或者"--"。
Specify linear and color.
Still define x as a vector of [0,10], and define Y1 and Y2 as two parallel lines. For example, "R --" indicates the "-" line shape with red color. We can also change the color or shape only, which is directly expressed as "R" or "-".
x=0:10
y1=3+4*x
y2=6+4*x
plot(x,y1,"r--",x,y2,"b:*")
04.坐标轴设计
Coordinate axis design
知道怎样绘制二维图形之后,我们来学习如何对坐标轴进行设计。
After knowing how to draw two-dimensional graphics, let"s learn how to design the coordinate axis.
(1)添加主题,坐标轴标签
使用 title 函数向图形添加标题,添加坐标轴标签;使用 xlabel 和 ylabel 函数向图形添加标题和坐标轴标签。
Add theme, axis labels
Use the title function to add a title to the drawing and add a coordinate axis label; Use the xlabel and ylabel functions to add titles and axis labels to the drawing.
title("x与y一元线性图")
xlabel("0 < x < 10") % x-axis label
ylabel("y值") % y-axis label
(2)添加图例。
使用 legend 函数向图形添加用于识别每个数据集的图例。按照绘制线条的顺序指定图例说明。
Add a legend.
Use the legend function to add a legend to the drawing that identifies each dataset. Specifies the legend description in the order in which the lines are drawn.
legend("y1=3+4*x","y2=6+4*x")
05.总结
Summary
本文通过plot函数,学习了如何绘制单线条的二维图形,以及多线条的二维图形;在此基础之上,介绍了如何改变线条形状和颜色,以及怎样设置标题,坐标轴标签和图例。对于二维画图还有很多内容需要学习,今天的内容都是基础,我们要勤加练习,并不断学习这样才能更好的掌握MATLAB的使用。
Through the plot function, this paper learned how to draw two-dimensional graphics of single line and two-dimensional graphics of multiple lines; On this basis, it introduces how to change the line shape and color, and how to set the title, coordinate axis label and legend. There is still a lot to learn about two-dimensional drawing. Today"s content is the foundation. We should practice frequently and keep learning, so as to better master the use of MATLAB.
今天的分享就到这里了。
如果您对今天的文章有独特的想法,
欢迎给我们留言,
让我们相约明天,
祝您今天过得开心快乐!
That"s it for today"s sharing.
If you have unique ideas about today’s article, please leave us a message,
Let us meet tomorrow,
I wish you a happy day today!
参考资料:谷歌翻译、MATLAB软件
本文由LearningYard学苑原创,如有侵权请沟通。
麦当劳,出鞋了素材图片均来源网络麦当劳,出鞋了!看鞋前,给大家10秒钟时间做个心理准备因为看完这鞋,再吃M记鸡块,可能会变得非常有味(单押skr)好了吧?那来吧你!谁能想到,麦当劳出鞋也就算了,
淘宝神客服回复,商家怼起客户了?图片素材来源于网络最近淘宝神回复火了。事情的缘起是这样一位网友在一家淘宝店里买了一个星球饰品后,给了个意味深长,故事满满的差评他不喜欢虽没有任何质量上或服务上的问题,但确实用四个字
王思聪与网红孙一宁互怼完整聊天记录王思聪与网红孙一宁开撕这才是这真大瓜啊,王思聪也有吃瘪的时候,网红职业王思聪喜怒无常!孙一宁大概得意思就是受不了王思聪的喜怒无常,甚至细数两人间的细节,而且从两人聊天记录来看,王思
B站崩了,段子比春晚还好笑图片素材源于网络字越少,事越大这句话的奥义已经在前天的热搜上尽数体现了B站崩了晋江崩了豆瓣崩了A站也崩了B站页面加载失败,请重试A站乖马上就好了晋江加载失败,您已取消页面加载豆瓣直
比王思聪更卑微的舔狗文案王校长的瓜大家都知道了,事情的经过基本就是你我本无缘,全靠我来舔,舔你不得逞,我就威胁你辱骂你曝光你略略略结果女方率先曝光聊天记录,导致王校长直接社死,撕葱土味情话大白天下,还被扣
余额宝,卖鞋了?素材源于网络大家下午好啊。余额宝,一个神奇的货币基金它的出场好像承载着一个特定时段的记忆那个时候拼多多还没有出现抖音也还没有爆火没有毕业的我们有关电商的讨论还停留在买电器上京东是真
拿来吧你,是什么梗?咋火的?素材来源于网络上一段时间是卑微文学,后来是勇敢牛牛,不怕困难,没想到这几天又开始流行起了拿来吧你这个网络梗。这个梗吧,现在就是理解到的小伙伴,觉得格外的魔性,而理解不了的朋友,觉得
比肩杜蕾斯,肛泰这半年赢麻了素材源于肛泰官方微博头图漫画源于微博胡渣少女的日常大家下午好啊有关于痔疮通常是大家会在有意无意间避开的话题但痔疮问题如果不重视起来经常是菊花残满地伤又或是爱你在菊花有痔口难开于是痔
清华腾讯商标被撤?商标撤三到底是什么?近年来,随着国家在战略层面上对知识产权的重视,以及竞争意识和市场推广等各种综合因素的影响,大家的商标保护意识普遍增强,撤三也开始逐年递增,慢慢进入大众视野!从国家商标局公布的数据来
我们的眼里已经不再只有清华北大说到清华北大那是很多父母还有莘莘学子眼里的光,那一年好好学习努力考清华北大是很多学子的口号。老师们也会鞭策你好好学习争取考上清华北大,小益之前也是对这两个学府有很深的向往,第一次来
如梦之梦武汉首映,肖战一个细节暴露了大家喜欢他的真正原因如梦之梦武汉首映,肖战一个细节暴露大家都喜欢他的真正原因近日肖战的新话剧如梦之梦在武汉首映,肖战的粉丝团们纷纷带着礼物和心意到现场呐喊助威。因肖战的粉丝太热情了,场外粉丝们送肖战的