matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(1)

分享兴趣,传播快乐,

增长见闻,留下美好。

亲爱的您,

这里是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.

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(2)

(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.

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(3)

(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, "*").

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(4)

(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.

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(5)

我们也可以同时指定线条形状和颜色,如'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.

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(6)

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)

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(7)

(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:*")

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(8)

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

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(9)

(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")

matlab绘制含有多词图(吴言乱语MATLAB基础学习之二维绘图)(10)

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学苑原创,如有侵权请沟通。

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页