快速入门matlab,系统地整理一遍,如何你和我一样是一个新手,那么此文很适合你;

1 前言

如果你是和我一样的小白,强烈推荐看看这里,需要合理地利用官方的文档,通常我觉得官方文档是最好的,没有之一,在命令终端输入help plot,可以看到详细的帮助文档;具体如下;

>> help plot

plot Linear plot.

plot(X,Y) plots vector Y versus vector X. If X or Y is a matrix,

then the vector is plotted versus the rows or columns of the matrix,

whichever line up. If X is a scalar and Y is a vector, disconnected

line objects are created and plotted as discrete points vertically at

X.

plot(Y) plots the columns of Y versus their index.

If Y is complex, plot(Y) is equivalent to plot(real(Y),imag(Y)).

In all other uses of plot, the imaginary part is ignored.

Various line types, plot symbols and colors may be obtained with

plot(X,Y,S) where S is a character string made from one element

from any or all the following 3 columns:

b blue . point - solid

g green o circle : dotted

r red x x-mark -. dashdot

c cyan + plus -- dashed

m magenta * star (none) no line

y yellow s square

k black d diamond

w white v triangle (down)

^ triangle (up)

< triangle (left)

> triangle (right)

p pentagram

h hexagram

For example, plot(X,Y,'c+:') plots a cyan dotted line with a plus

at each data point; plot(X,Y,'bd') plots blue diamond at each data

point but does not draw any line.

plot(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by

the (X,Y,S) triples, where the X's and Y's are vectors or matrices

and the S's are strings.

For example, plot(X,Y,'y-',X,Y,'go') plots the data twice, with a

solid yellow line interpolating green circles at the data points.

The plot command, if no color is specified, makes automatic use of

the colors specified by the axes ColorOrder property. By default,

plot cycles through the colors in the ColorOrder property. For

monochrome systems, plot cycles over the axes LineStyleOrder property.

Note that RGB colors in the ColorOrder property may differ from

similarly-named colors in the (X,Y,S) triples. For example, the

second axes ColorOrder property is medium green with RGB [0 .5 0],

while plot(X,Y,'g') plots a green line with RGB [0 1 0].

If you do not specify a marker type, plot uses no marker.

If you do not specify a line style, plot uses a solid line.

plot(AX,...) plots into the axes with handle AX.

plot returns a column vector of handles to lineseries objects, one

handle per plotted line.

The X,Y pairs, or X,Y,S triples, can be followed by

parameter/value pairs to specify additional properties

of the lines. For example, plot(X,Y,'LineWidth',2,'Color',[.6 0 0])

will create a plot with a dark red line width of 2 points.

Example

x = -pi:pi/10:pi;

y = tan(sin(x)) - sin(tan(x));

plot(x,y,'--rs','LineWidth',2,...

'MarkerEdgeColor','k',...

'MarkerFaceColor','g',...

'MarkerSize',10)

与plot相关的函数还有 plottools, semilogx, semilogy, loglog, plotyy, plot3, grid,title, xlabel, ylabel, axis, axes, hold, legend, subplot, scatter.

2 plot

2.1 显示正弦波

显示一个简单的正弦函数;

x=0:2*pi/100:2*pi;

y=sin(x);

plot(x,y);

2.2 修改颜色

下面修改为红色:

x=0:2*pi/100:2*pi;

y=sin(x);

plot(x,y,'r');

结果如下:

2.3 修改点的形状

参数

形状

图标

-

solid

o

circle

x

x-mark

+

plus

*

star

s

square

d

diamond

v

triangle (down)

^

triangle (up)

<

triangle (left)

>

triangle (right)

p

pentagram

h

hexagram

将点形状显示为六边形;

x=0:2*pi/20:2*pi;

y=sin(x);

plot(x,y,'h','MarkerSize',10);

结果如下:

相关参数:

MarkerEdgeColor:点边框颜色;

MarkerFaceColor:点表面颜色;

MarkerSize:点的大小;

2.4 修改线的形状

符号

形状

:

dotted

-.

dashdot

--

dashedx=0:2*pi/20:2*pi;

y=sin(x);

plot(x,y,':','LineWidth',3);

LineWidth的参数为线宽;

x=0:2*pi/20:2*pi;

y=sin(x);

plot(x,y,'-.','LineWidth',3);

x=0:2*pi/20:2*pi;

y=sin(x);

plot(x,y,'--','LineWidth',3);

2.5 多个参数修改

下面修改多个参数属性显示一下正弦波;

x = 0:2*pi/100:2*pi;

y = sin(x);

plot(x,y,'--rs','LineWidth',2,...

'MarkerEdgeColor','k',...

'MarkerFaceColor','g',...

'MarkerSize',10);

结果如下:

3 subplot

subplot的使用方法如下:

subplot Create axes in tiled positions.

H = subplot(m,n,p), or subplot(mnp), breaks the Figure window

into an m-by-n matrix of small axes, selects the p-th axes for

the current plot, and returns the axes handle. The axes are

counted along the top row of the Figure window, then the second

row, etc. For example,

subplot(2,1,1), PLOT(income)

subplot(2,1,2), PLOT(outgo)

通俗的讲:

subplot(行,列,index)

注意:plot函数要在subplot表明位置之后再调用。

3.1 2行1列

x=0:2*pi/20:2*pi;

y=sin(x);

subplot(2,1,1);

plot(x,y,'y','LineWidth',3);

subplot(2,1,2);

plot(x,y,'g','LineWidth',3);

需要将多个波形显示在同一张图中;

3.2 1行2列

x=0:2*pi/20:2*pi;

y=sin(x);

subplot(1,2,1);

plot(x,y,'y','LineWidth',3);

subplot(1,2,2);

plot(x,y,'g','LineWidth',3);

4 plot3

t = 0:pi/50:10*pi;

plot3(sin(t),cos(t),t);

5 title

title:图的标题;

xlabel:x轴标题;

ylabel:y轴标题;

指定plot的标题,需要在plot调用之后在调用title,xlabel或ylabel;

x=0:2*pi/20:2*pi;

y=sin(x);

subplot(1,2,1);

plot(x,y,'y','LineWidth',3);

title('yellow');

xlabel('yellow-x');

ylabel('yellow-y');

subplot(1,2,2);

plot(x,y,'g','LineWidth',3);

title('green');

xlabel('green-x');

ylabel('green-y');

6 legend

x = 0:.2:12;

plot(x,besselj(1,x),x,besselj(2,x),x,besselj(3,x));

legend('First','Second','Third','Location','NorthEastOutside')

b = bar(rand(10,5),'stacked'); colormap(summer); hold on

x = plot(1:10,5*rand(10,1),'marker','square','markersize',12,...

'markeredgecolor','y','markerfacecolor',[.6 0 .6],...

'linestyle','-','color','r','linewidth',2); hold off

legend([b,x],'Carrots','Peas','Peppers','Green Beans',...

'Cucumbers','Eggplant')

这是官方的demo,比较复杂;

x=0:2*pi/20:2*pi;

y=sin(x);

plot(x,y,':','LineWidth',3);

legend('test1');

legend需要在plot之后调用,用于依次解释第一个plot的波形,如果一个plot里显示了两个波形,那legen中字符串也需要设置两个,分别依次对应plot中的波形;

7 at last

比较简单,matplotlib的功能和这个比较类似,总体来说,作为一个和博主一样的新手,要多看官方的help文档,然后平时使用的过程中慢慢就熟悉了,最后要多总结。

作者能力有限,文中难免有错误和纰漏之处,请大佬们不吝赐教

创作不易,如果本文帮到了您;

请帮忙点个赞

stackedplot 函数_【matlab 基础篇 03】一文带你全面了解 plot 绘图函数的使用(超详细+图文并茂)...相关推荐

  1. K8S实战基础篇:一文带你深入了解K8S实战部署SpringBoot项目

    K8S实战基础篇:一文带你深入了解K8S实战部署SpringBoot项目 1.前言 2.简介 2.1.为什么写这篇文章 2.2.需求描述 2.3.需求分析 3. 部署实战 3.1 环境准备 3.2 i ...

  2. MATLAB基础篇——微积分应用

    MATLAB基础篇--微积分应用 函数极限 导数 定积分与不定积分 二重积分与三重积分 曲线积分 曲面积分 级数 微分方程和微分方程组的解析解 函数极限 limit函数: limit(f,x,a,'l ...

  3. MATLAB基础篇——数值分析篇

    MATLAB基础篇--数值分析篇 1.solve求解方程/方程组(不涉及微积分运算) 格式: syms 符号变量(要求解的变量) solve(方程左边==方程右边,符号变量) 例子: (1)求解方程x ...

  4. 一些解密必备知识(2)- 基础篇03|解密系列

    一些解密必备知识(2)- 基础篇03 让编程改变世界 Change the world by program   软件安全是信息安全领域的重要内容,本系列视频教程将涉及到软件相关的加密.解密.逆向分析 ...

  5. C++ 学习 ::【基础篇:13】:C++ 类的基本成员函数:类类型成员的初始化与构造函数问题

    本系列 C++ 相关文章 仅为笔者学习笔记记录,用自己的理解记录学习!C++ 学习系列将分为三个阶段:基础篇.STL 篇.高阶数据结构与算法篇,相关重点内容如下: 基础篇:类与对象(涉及C++的三大特 ...

  6. 修改pom文件_自动化测试基础篇:Selenium 框架设计(POM)

    (给Python开发者加星标,提升Python技能) 来源:  叁藏法师 https://www.cnblogs.com/sanzangTst/p/8376550.html [导语]Selenium是 ...

  7. 圆形界面 开启相机_「基础篇三」手机摄影拍照界面详解

    ​[基础篇三]手机摄影拍照界面详解 手机拍照对我们来说已习以为常,每天我们都会用手机相机功能或多或少的拍出几张照片.故手机拍照界面对我们来说也不陌生,但手机拍照界面上的那些按钮,那些功能你都用过吗?你 ...

  8. swap函数_[C++基础入门] 6、函数

    点击上方 蓝字 关注我呀! [C++基础入门] 6.函数 文章目录 6 函数 6.1 概述 6.2 函数的定义 6.3 函数的调用 6.4 值传递 6.5 函数的常见样式 6.6 函数的声明 6.7 ...

  9. spring 点击保存按钮页面禁用_用一篇深度好文,详解按钮的设计

    本文共 2092 字,预计阅读 10 分钟,记得点击上面的 蓝字 关注我哦- 为了设计更好的用户界面,我们常常需要回顾它的历史和起源.按钮在界面设计中很重要.在物理按钮时期,手指的轻微触碰可以使设备. ...

最新文章

  1. P1772 [ZJOI2006]物流运输
  2. 使用Unified Auditing Policy审计数据泵导出操作
  3. java判断点与线与面的关系_VC++开发GIS系统(280)判断点与面的拓扑关系
  4. win 2008 控制共享文件夹大小_Windows 10 无法访问共享的解决办法大全
  5. html 点击子元素,html如何点击子元素事件而不触发父元素的点击事件——阻止冒泡...
  6. Eclipse错误:Syntax error on tokens, delete these tokens问题解决
  7. 京东金融 App 收集隐私?开源库程序员不背锅!
  8. ftp连接工具,8款免费又好用的ftp连接工具
  9. System State 转储分析案例一则
  10. 贝壳DMP平台建设实践
  11. 治疗失眠的中医食疗方
  12. 2021年全球拍立得消耗品(胶片和相纸)收入大约205.8百万美元,预计2028年达到291百万美元
  13. maven命令的方式
  14. 从明日方舟入手数据统计--盒须图
  15. python泰坦尼克号案例分析_Python机器学习案例-泰坦尼克之灾
  16. WVGA与HVGA、QVGA详细解答
  17. 信息学奥赛一本通C++语言-----2036:【例5.3】开关门
  18. 吴裕雄--天生自然 诗经:长恨歌
  19. 【创建petstore数据库与表】
  20. MATLAB绘制xyz的分段函数,matlab绘制分段函数

热门文章

  1. JMeter 5.0: 自定义变量
  2. 礼物精选 个性化礼品推荐平台
  3. JQuery核心:1.jQuery( expression, context )
  4. drx功能开启后_KZ正式更名为DRX,LCK将解锁全部选手的“第一视角观赛”功能 | 电竞头条...
  5. [深入理解Android卷一全文-第七章]深入理解Audio系统
  6. 迷你云服务器怎么开,迷你云服务器
  7. 删除已经提交到远程仓库的gitignore文件
  8. 同构处理器和异构处理器的区别
  9. ironpython是什么意思_ironpython2.0以后,基于.net的什么特性
  10. C语言输出长长整型错误,c语言长整型定义