龙空技术网

周一分享(九):Matlab二维绘图1

LearningYard学苑 150

前言:

现在各位老铁们对“matlab画图定义横纵坐标”大体比较关心,你们都需要了解一些“matlab画图定义横纵坐标”的相关知识。那么小编同时在网络上汇集了一些关于“matlab画图定义横纵坐标””的相关资讯,希望看官们能喜欢,咱们快快来了解一下吧!

Matlab二维绘图

Matlab 2D plot

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

亲爱的您,

这里是LearingYard学苑!

今天小编为大家带来Matlab二维绘图。

欢迎您的用心访问!

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

Share interest, spread happiness,

increase knowledge, and leave beautiful.

Dear you,

this is the LearingYard Academy!

Today, the editor brings two-dimensional drawing in Matlab.

Welcome your visit!

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

二维绘图基本语法

2D Drawing Basic Syntax

plot(X,Y) 创建Y中数据对X中对应值的二维线图。要绘制由线段连接的一组坐标,请将X和 Y指定为相同长度的向量。要在同一组坐标轴上绘制多组坐标,请将X或Y中的至少一个指定为矩阵。plot(X,Y,LineSpec) 使用指定的线型、标记和颜色创建绘图。plot(X1,Y1,...,Xn,Yn) 在同一组坐标轴上绘制多对x和y坐标。plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) 可为每个x-y对组指定特定的线型、标记和颜色。可以对某些x-y对组指定 LineSpec,而对其他对组省略它。plot(X1,Y1,'o',X2,Y2)对第一个 x-y 对组指定标记,但没有对第二个对组指定标记。legend为每个绘制的数据序列创建一个带有描述性标签的图例。subplot(m,n,p) 将当前图窗划分为m×n网格,并在p指定的位置创建坐标区。gtext(str)在使用鼠标选择的位置插入文本str。当鼠标指针悬停在图窗窗口上时,指针变为十字准线。将鼠标指针移至所需位置并点击图窗或按任意键gtext(str,Name,Value) 使用一个或多个名称值对组参数指定文本属性。plot(X,Y) creates a 2-D line plot of the data in Y versus the corresponding values in X . To draw a set of coordinates connected by line segments, specify X and Y as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix.plot(X,Y,LineSpec) creates a plot with the specified linetype, markers, and colors.plot(X1,Y1,...,Xn,Yn) plots pairs of x and y coordinates on the same set of axes.plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) assigns specific line styles, markers, and colors to each x-y pair. You can specify LineSpec for some x-y pairs and omit it for others.plot(X1,Y1,'o',X2,Y2) assigns a marker to the first x-y pair, but does not assign a marker to the second pair.legend creates a legend with descriptive labels for each plotted data series. subplot(m,n,p) divides the current figure into an m-by-n grid and creates the axes at the locations specified by p.gtext(str) Inserts the text str at the location you selected with the mouse. When you hover the mouse pointer over the figure window, the pointer changes to a crosshair. Move the mouse pointer to the desired location and click the figure or press any keygtext(str,Name,Value) specifies a text attribute using one or more name-value pair arguments.

示例

Example

01

绘制sinx图像

Draw sinx image

代码如下图所示:

The code is shown below:

运行结果如下图所示:

The running result is shown in the following figure:

02

绘制sinx图像,改变线型,颜色

Draw sinx image, change line type, color

代码如下图所示:

The code is shown below:

运行结果如下图所示:

The running result is shown in the following figure:

03

绘制sinx图像,并标注标题,横纵坐标、图例

Draw a sinx image, and label the title, xlabel,ylabel and legend

代码如下图所示:

The code is shown below:

运行结果如下图所示:

The running result is shown in the following figure:

04

创建一个分为四个子图的图窗。绘制2个正弦曲线,2个余弦曲线并为每个子图指定标题。

Create a figure divided into four subplots. Plot 2 sine curves, 2 cosine curves and give each subplot a title.

代码如下图所示:

The code is shown below:

运行结果如下图所示:

The running result is shown in the following figure:

05

绘制sinx和cosx图像,分别注明名称值

Plot sinx and cosx images with name values respectively

代码如下图所示:

The code is shown below:

运行结果如下图所示:

The running result is shown in the following figure:

今天的分享就到这里了。

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

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

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学苑原创,如有侵权请在后台留言!

文字|Zheng

排版|Zheng

审核|任务达人

标签: #matlab画图定义横纵坐标