matlab画图怎么在线上标注(宏记软件二)

matlab画图怎么在线上标注(宏记软件二)(1)

分享兴趣,传播快乐,增长见闻,留下美好。

亲爱的您。

这里是LearingYard学苑!

今天小编为大家带来Matlab二维绘图及label语法.

欢迎您的用心访问!

本期推文阅读时长大约5分钟,请您耐心阅读。

Share interest, spread happiness,

increase knowledge, and leave beautiful.

Dear you.

This is the LearingYard Academy!

Today, the editor brings Matlab two-dimensional drawing and label syntax.

Welcome your visit!

The reading time of this tweet is about 5 minutes, please read it with patience.

大家好,上期系列推文介绍了二维绘图中的线性图如何制作(plot函数),这期介绍其他类型的二维图如何制作以及所用的函数,另外介绍label函数的使用方法。

Hello everyone, the last series of tweets introduced how to make linear graphs in 2D drawing (plot function). This issue introduces how to make other types of 2D graphs and the functions used. In addition, it introduces how to use the label function.

一.条形图

在Matlab创建垂直条形图一般使用的是bar(英文是条纹,栏的意思) 函数,而创建水平条形图用的是barh 函数。操作如下:

左边代码为

y=[60 90 105 115 130 150 170 195 210 235 270] bar(y)

很好理解,对y集合的各个元素赋值,然后用bar函数将y以竖向条形图的形式输出。当然也可以使用其他的数学函数,这里只用了简单的集合。

1. Bar Chart

The bar function is generally used to create vertical bar charts in Matlab, while the barh function is used to create horizontal bar charts. The operation is as follows:

The code on the left is

y=[60 90 105 115 130 150 170 195 210 235 270] bar(y)

is well understood, assigns values to each element of the y set, and then uses the bar function to output y in the form of a bar graph. Of course other mathematical functions can be used, but only simple sets are used here.

matlab画图怎么在线上标注(宏记软件二)(2)

用barh函数将bar函数替换就能得到横向条形图:

Replacing the bar function with the barh function yields the following image:

matlab画图怎么在线上标注(宏记软件二)(3)

二. 阶梯图

在Matlab创建阶梯图一般使用的是stairs(英文阶梯的含义)函数。使用方法如下

左边为代码为x = 0:0.5:20;

y = sin(2*x);

stairs(x,y)

含义是自变量x 在0-20范围,并且0.5间隔取一点,因变量为sin(2*x),使用stairs输出x,y。

2.Step diagram

Stairs (the meaning of English steps) function is generally used to create ladder diagrams in Matlab. The method of use is as follows

The code on the left is x = 0:0.5:20;

y = sin(2*x);

stairs(x,y)

The meaning is that the independent variable x is in the range of 0-20, and a point is taken at 0.5 intervals, the dependent variable is sin(2*x), and stairs is used to output x, y.

matlab画图怎么在线上标注(宏记软件二)(4)

三. 散点图

在Matlab创建散点图一般使用的是scatter函数。使用方法如下:

左边为代码为x=linspace(0,4*pi,150)

y=sin(x) rand(1,150)

scatter(x,y)

含义是x在0-4π中等距离取150个点,因变量y=sin(x) (大小在0-1之前1列150行的矩阵里随机数),最后用scatter函数输出。

3.Scatter plot

The scatter function is generally used to create scatter plots in Matlab. The method of use is as follows:

The code on the left is x=linspace(0,4*pi,150)

y=sin(x) rand(1,150)

scatter(x,y)

The meaning is that x takes 150 points at an intermediate distance of 0-4π, the dependent variable y=sin(x) (random number in the matrix with 1 column and 150 rows before 0-1), and finally uses the scatter function to output.

matlab画图怎么在线上标注(宏记软件二)(5)

四. 极坐标图

在Matlab创建散点图一般使用的是polarplot函数,此函数可以在极坐标中绘制线条。极坐标图需要结合 theta 和rho 函数来使用。使用方法如下:

其中theta 是角度值,rho 是半径值,对这两个赋值之后,使用polarplot进行输出。

4.Polar plot

The polarplot function is generally used to create scatter plots in Matlab, which can draw lines in polar coordinates. Polar plots need to be used in conjunction with theta and rho functions. The method of use is as follows:

where theta is the angle value and rho is the radius value. After assigning these two values, use polarplot to output.

matlab画图怎么在线上标注(宏记软件二)(6)

五. label函数

label函数有多种使用方法,比较常用的有xlabel、ylabel、labeledge、labelText等等。下面介绍在这四种函数.

xlabel函数指在x轴上添加标签,ylabel函数指在y轴上添加标签,用上面已经画过的图举例:

5.label function

There are many ways to use the label function, the more commonly used ones are xlabel, ylabel, labeledge, labelText and so on. These four functions are described below.

The xlabel function refers to adding a label to the x-axis, and the ylabel function refers to adding a label to the y-axis. Take the figure already drawn as an example:

matlab画图怎么在线上标注(宏记软件二)(7)

labeledge函数指为图边添加标签,labelText打上文本标签。我们通过一个无向边图说明如何使用这两个函数。

先画一个无向图:

The labeledge function refers to adding labels to the image edges, and labelText labels the text. We illustrate how to use these two functions through an undirected edge graph.

First draw an undirected graph:

matlab画图怎么在线上标注(宏记软件二)(8)

labeledge 可以添加权重标签,labelText可以添加文本标签

labeledge使用 :

weights = [5 10 15 20 25];

labeledge(h,1:numedges(N),weights)

先设置权重,再添加进去。

labeledge can add edge weight labels, labelText can add text labels

labeledge uses:

weights = [5 10 15 20 25];

labeledge(h,1:numedges(N),weights)

set the weight first, then add it.

matlab画图怎么在线上标注(宏记软件二)(9)

labelText使用:

labelText = {'A'};

labeledge(h,[1],labelText)

先写文本 再将文本内容标在第一条边上。

labelText uses:

labelText = {'A'};

labeledge(h,[1],labelText)

Write the text first When speaking, the text content is marked on the first edge.

matlab画图怎么在线上标注(宏记软件二)(10)

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's it for today's sharing.

If you have a unique idea about today’s article,

welcome to leave us a message,

let us meet tomorrow.

I wish you a happy day today!

参考资料:谷歌翻译

本文由LearningYard整理发出,如有侵权请在后台留言!

文字 | clear

排版| clear

审核| 任务达人

,

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

    分享
    投诉
    首页