第四章:Graph

Plot form 'Data'

 plot(x,y);
 plot(y);    %x = [1…n], n = length(y)
 EG1:
 plot(cos(0:pi/20:2*pi));
 EG1.1:
 plot(cos(0:pi/20:2*pi));
 plot(sin(0:pi/20:2*pi));    %会覆盖旧的图形,除非使用hold指令
 ​
 hold on/off
 EG:
 hold on
 plot(cos(0:pi/20:2*pi));
 plot(sin(0:pi/20:2*pi));    %两个图像在一个坐标轴
 hold off
 ​
 plot(x,y,'str')
 %str是图像的一些参数进行一个改变的动作,具体指令如下所示
  1. Data markers

    • Dot(.)——.

    • Asterisk( * )——*

    • Cross(×)——X

    • Circle(○)——o

    • Plus sign(+)——+

    • Square(□)——s

    • Diamond(♢)——d

    • Five-pointed star(☆)——p

    • Triangle(下三角)——v

    • Triangle(上三角)——^

    • Triangle(左三角【指向右边】)——<

    • Triangle(右三角【指向左边】)——>

    • hexagram——H

  2. Line types

    • Solid line -

    • Dashed line --

    • Dash-dotted line -.

    • Dotted line :

  3. Colors

    • Black——k

    • Blue——b

    • Cyan——c

    • Green——g

    • Magenta——m

    • Red——r

    • White——w

    • Yellow——y

更多详情查看linespec

 legend()
 %标记图例
 EG1:
 x = 0:0.5:4*pi;
 y = sin(x);
 h = cos(x);
 w = 1./(1+exp(-x));
 g = (1/(2*pi*2)^0.5).*exp((-1.*(x-2*pi).^2)./(2*2^2));
 plot(x,y,'bd-',x,h,'gp',x,w,'ro-',x,g,'c^-');
 legend('sin(x)','cos(x)','Sigmoid','Gauss function');
 title()
 xlabel()
 ylabel()
 zlabel()   %三维画图
 %加标题
 EG:
 x = 0:0.1:2*pi;
 y1 = sin(x);
 y2 = exp(-x);
 plot(x,y1,'--*',x,y2,':o');
 xlabel('t = 0 to 2\pi');   %输出2π,如果input‘2π’,output‘6.28’
 ylabel('values of sin(t) and e^{-x}');   %特殊字符e^{-x}
 title('Function Plots of sin(t) and e^{-x}');
 legend('sin(t)','e^{-x}');
 text() and annotation()
 %使用LaTex达到一些花里胡哨的效果
 EG1:
 x = linspace(0,3);   %定义域
 y = x.^2.*sin(x);
 plot(x,y);
 line([2,2],[0,2^2*sin(2)]);    %在图上画一个line
 str = '$$ \int_{0}^{2} x^2\sin(x) dx $$';   %表示定积分符号
 text(0.25,2.5,str,'Interpreter','latex');   %后面的两个引号是固定表示,详情自查
 annotation('arrow','X',[0.32,0.5],'Y',[0.6,0.4]);  %生成箭头

Figure Adjustment

Graphical Objects: Figure,Axes,Line

Handle of An Object

 gca   %axes
 gcf   %figure
 allchild   %find all children of specified objects
 ancestor   %find ancestor of graphics object
 delete   %delete an object
 findall   %dinf all graphics objects

Fetch or Modifying Properties

  • To fetch properties

 get();
 eg1:
 x = linspace(1,2*pi,1000);
 y = sin(x);
 plot(x,y);
 h = plot(x,y);
 get(h);
 get(gca)
 eg2:
 set(gca,'XLim',[0,2*pi]);
 set(gca,'YLim',[-1.2,1.2]);
 set(gca,'FontSize',25);   %坐标数字大小
 %%
 set(gca,'XTick',0:pi/2:2*pi);   %坐标点位
 set(gca,'XTickLabel',0:90:360);    %坐标表示
 %%
 set(gca,'FontName','symbol');    %转handle
 set(gca,'XTickLabel',{'0','p/2','p','3p/2','2p'});    %改表示

Line Specification

 set(h,'LineStyle','-.','LineWidth',7.0,'Color','g');
 %%
 plot(x,y,'-.g',...,'LineWidth',7.0);
 %delete(),删除图像,但是不删除变量

Maker Specification

 x = rand(20,1);
 set(gca,'FontSize',18);
 plot(x,'-md','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColoe'...
  'g','MarkerSize',10);
 xlim([1,20]);

Multiple Figures

x = -10:0.1:10;
y1 = x.^2-8;
y2 = exp(x);
figure
plot(x,y1);
figure
plot(x,y2);
%gca与gcf只能找到最新的图像
figure('Position',[left,bottom],width,height);
%%%%%%%
subplot(m,n,1); %多图放一张 n:column;m:row;1:1~n个图
eg:
t = 0:0.1:2*pi;
x = 3*cos(t);
y = sin(t);
subplot(2,2,1);
plot(x,y);
axis normal;
subplot(2,2,2);
plot(x,y);
axis square; %x与y轴的整体长度相等
subplot(2,2,3);
plot(x,y);
axis equal; %x与y轴上面的单位长度等距
subplot(2,2,4);
plot(x,y);
axis equal tight; %贴近图像
grid on/off    %格线
box on/off %边框
axis on/off %坐标图
axis nomal
axis aquare
axis equal
axis equal tight
axis image
axis ij
axis xy
%自查

Saving Figures into Files

saveas(gcf,'<filename>','<formattype>');
%%%%%%
---Bitmap
jpeg
png
tiff
bmpmono
bmp
bmp256 ---Vector(sanse推荐)
pdf
eps
epsc
meta
svg
ps
psc %更多查询print

Matlab %肆的更多相关文章

  1. Matlab 绘制三维立体图(以地质异常体为例)

    前言:在地球物理勘探,流体空间分布等多种场景中,定位空间点P(x,y,x)的物理属性值Q,并绘制三维空间分布图,对我们洞察空间场景有十分重要的意义. 1. 三维立体图的基本要件: 全空间网格化 网格节 ...

  2. Matlab slice方法和包络法绘制三维立体图

    前言:在地球物理勘探,流体空间分布等多种场景中,定位空间点P(x,y,x)的物理属性值Q,并绘制三维空间分布图,对我们洞察空间场景有十分重要的意义. 1. 三维立体图的基本要件: 全空间网格化 网格节 ...

  3. Matlab 高斯_拉普拉斯滤波器处理医学图像

    前言:本程序是我去年实现论文算法时所做.主要功能为标记切割肝脏区域.时间有点久,很多细节已经模糊加上代码做了很多注释,因此在博客中不再详述. NOTE: 程序分几大段功能模块,仔细阅读,对解决医学图像 ...

  4. MATLAB中绘制质点轨迹动图并保存成GIF

    工作需要在MATLAB中绘制质点轨迹并保存成GIF以便展示. 绘制质点轨迹动图可用comet和comet3命令,使用例子如下: t = 0:.01:2*pi;x = cos(2*t).*(cos(t) ...

  5. linux下配置matlab运行环境(MCR)

    在安装好的matlab下有MCR(MatlabCompilerRuntime)在matlab2011/toolbox/compiler/deploy/glnxa64下找到MCRInstaller.zi ...

  6. EMD分析 Matlab 精华总结 附开源工具箱(全)

    前言: 本贴写于2016年12与15日,UK.最近在学习EMD(Empirical Mode Decomposition)和HHT(Hilbert-Huang Transform)多分辨信号处理,FQ ...

  7. Atitit MATLAB 图像处理 经典书籍attilax总结

    Atitit MATLAB 图像处理 经典书籍attilax总结 1.1. MATLAB数字图像处理1 1.2. <MATLAB实用教程(第二版)>((美)穆尔 著)[简介_书评_在线阅读 ...

  8. Atitit MATLAB 图像处理attilax总结

    Atitit MATLAB 图像处理attilax总结 1.1. 下载 Matlab7.0官方下载_Matlab2012 v7.0 官方简体中文版-办公软件-系统大全.html1 1.2. Matla ...

  9. Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结

    Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结 1.1. 边缘检测的基本方法Canny最常用了1 1.2. 编写matlab边缘检测代码, ...

  10. 使用MATLAB对图像处理的几种方法(下)

     试验报告 一.试验原理: 图像点处理是图像处理系列的基础,主要用于让我们熟悉Matlab图像处理的编程环境.灰度线性变换和灰度拉伸是对像素灰度值的变换操作,直方图是对像素灰度值的统计,直方图均衡是对 ...

随机推荐

  1. maven的setting.xml配置文件详解

    <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://mav ...

  2. dockerfile实践学习

    一.dockerfile简介 镜像是分层存储的,每一层在前一层的基础上进行修改. 容器也是分层存储,已经向为基础层,在其他基础上加一层作为容器运行的存储层. 创建镜像的另种两种方法 手动修改容器内容, ...

  3. vuex状态管理器

    vuex核心概念 // vuex中一共有五个状态 State Getter Mutation Action Module import Vue from 'vue' import Vuex from ...

  4. gin web 2

    routers/router.go package routers import ( "github.com/gin-gonic/gin" "gin-blog/pkg/s ...

  5. react 脚手架搭建项目 报错C:\Program Files\nodejs\node_cache\_logs\2022-12-28T14_38_28_286Z-debug-0.log

    报错内容: 解决方法: 第一步: 删除C:\Program Files\nodejs\node_cache\_logs 目录下所有文件 第二步:切换镜像 npm config set registry ...

  6. C++11 mutex unique_lock condition_variable 互斥锁 条件变量

    创建项目再进行测试比较麻烦,可以使用这个在线编译器进行验证,快速方便 C++11在线编译器 mutex是互斥锁,互斥量 condition_variable是条件变量 std::mutex m; vo ...

  7. 7. 交换排序的阈值(swapThreshold)

    1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta charset="U ...

  8. js时间转化为几天前,几小时前,几分钟前

    在前面一篇文章中,我们学习到了如何获取时间和怎么算出两者之间的时间差 今天看看怎么将时间戳转换为几个月前,几周前,几天前,几分钟前的形式.与上面类似通过JavaScript计算当前时间与定义的时间的对 ...

  9. 分布式事务 seata

    seata-server-1.3.0   配置: file.conf: registry.conf: application.yml配置: 配置中心配置文件: 数据库: 使用:

  10. 把一个元器件的原理图分成多个Part-转载

    (24条消息) [AD20]把一个元器件的原理图分成多个Part_不知道在干嘛每天的博客-CSDN博客_ad中原理图怎么分成几部分 以LM358芯片为例:把LM358原理图的A和B分开画,分成A和B两 ...