第四章: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. dart extends 覆盖规则

    1,不覆写super的变量,child会自动继承super的变量.即使是在child里给super赋值,child里也是可以访问到的,可能是因为引用的关系. 2,只要覆写了super的变量,只给sup ...

  2. go web编程学习记录

    学习 https://segmentfault.com/a/1190000013297625的记录 简单demo package main import "github.com/gin-go ...

  3. 摹客RP,编辑界面缩放比例支持手动输入!

    Hello,小伙伴们,又到了摹客的新功能播报时间. 本月更新,摹客RP编辑界面缩放比例支持手动输入,并对部分组件的默认样式及属性进行了优化:摹客DT率先上线了3款黄金比例图层,辅助设计师更高效绘图:针 ...

  4. 【1】java之类与对象

    一.前言 面向对象就是一种组件化的设计思想. 面向对象特性 封装性:保护内部的定义结构安全性: 继承性:在已有的程序结构上继续扩充新的功能: 多态性:在某一个概念范围内的满足. 二.类与对象的定义和使 ...

  5. AtCoder Beginner Contest 272 - G - Yet Another mod M

    随机 + 数论 题意 Submission #35524126 - AtCoder Beginner Contest 272 给一个长度为 \(n\;(1<=n<=5000)\) 的数组 ...

  6. WPFprism框架

    1. Prism 简介Prism 是一个用于构建松耦合.可维护和可测试的 XAML 应用的框架,它支持所有还活着的基于 XAML 的平台,包括 WPF.Xamarin Forms.WinUI 和 ~~ ...

  7. umi build出现的Path must be a string的问题解决

    问题 使用umi build出现的Path must be a string恶心解决方法 umi build出现的Path must be a string的问题解决 解决方案 参考链接:https: ...

  8. dialog弹窗里生成二维码 (reading qppendChild)

    在dialog弹窗里生成二维码第一次点击时 dialogFormVisible.value=false,二维码生成时会找不到对象可以用nextTick()函数 将二维码生成代码放到nextTick() ...

  9. windows检查

    # coding: UTF-8 import psutil import platform import re def get_cpu_used(upu_base, interval=1): perc ...

  10. centos 7 安装rocketmq 主从

    https://www.cnblogs.com/weianlai/p/14590533.html