1.官方给出的解释:(看不懂就直接略过看下面实例)

%GRADIENT Approximate gradient.
%   [FX,FY] = GRADIENT(F) returns the numerical gradient of the
%   matrix F. FX corresponds to dF/dx, the differences in x (horizontal) 
%   direction. FY corresponds to dF/dy, the differences in y (vertical) 
%   direction. The spacing between points in each direction is assumed to 
%   be one. When F is a vector, DF = GRADIENT(F) is the 1-D gradient.
%
%   [FX,FY] = GRADIENT(F,H), where H is a scalar, uses H as the
%   spacing between points in each direction.
%
%   [FX,FY] = GRADIENT(F,HX,HY), when F is 2-D, uses the spacing
%   specified by HX and HY. HX and HY can either be scalars to specify
%   the spacing between coordinates or vectors to specify the
%   coordinates of the points.  If HX and HY are vectors, their length
%   must match the corresponding dimension of F.
%
%   [FX,FY,FZ] = GRADIENT(F), when F is a 3-D array, returns the
%   numerical gradient of F. FZ corresponds to dF/dz, the differences
%   in the z direction. GRADIENT(F,H), where H is a scalar, 
%   uses H as the spacing between points in each direction.
%
%   [FX,FY,FZ] = GRADIENT(F,HX,HY,HZ) uses the spacing given by
%   HX, HY, HZ. 
%
%   [FX,FY,FZ,...] = GRADIENT(F,...) extends similarly when F is N-D
%   and must be invoked with N outputs and either 2 or N+1 inputs.
%
%   Note: The first output FX is always the gradient along the 2nd
%   dimension of F, going across columns.  The second output FY is always
%   the gradient along the 1st dimension of F, going across rows.  For the
%   third output FZ and the outputs that follow, the Nth output is the
%   gradient along the Nth dimension of F.

2.举个栗子

定义一个二维矩阵x,求其梯度:

由上图可知,梯度值Fx(i,j)可分为三个部分:

左边界梯度: Fx(:,j) = Fx(:,j+1) - Fx(:,j) ;

右边界梯度: Fx(:,j) = Fx(:,j) - Fx(:,j-1);

中间区域梯度: Fx(:,j) = (Fx(:,j+1) - Fx(:,j-1)) / 2.

同理,可以得出Fy,此处不再赘述。

matlab 中gradient()函数的用法相关推荐

  1. matlab roundn函数_columns函数的使用方法 matlab中round函数具体用法

    Excel中column函数的使用方法是什么?其实小编会说分手是想被挽留,你却顺口祝小编自由. 只读属性,返回 TextStream 文件中当前字符位置的列号. 语法: =Column(referen ...

  2. MATLAB中randi函数的用法

    MATLAB中randi函数的用法 均匀分布的伪随机整数 语法 X = randi(imax) X = randi(imax,n) X = randi(imax,sz1,...,szN) X = ra ...

  3. MATLAB中freqz函数的用法

    本文引用自乱七八糟<MATLAB中freqz函数的用法>  FREQZ 是计算数字滤波器的频率响应的函数 [H,W] = FREQZ(B,A,N)returns the N-point c ...

  4. Matlab中linprog函数的用法总结

    Matlab中 linprog函数的用法总结 1.简介 在matlab中,linprog函数可以求解线性规划问题,用于寻找目标函数的最小值 matlab中,规划模型的标注写法如下 \[ min\ f\ ...

  5. Matlab中min函数的用法

    Matlab中min函数的用法 向量中的最小元素 创建一个向量并计算其最小元素. M = min(A) A = [23 42 37 15 52]; M = min(A)M = 15 每个矩阵列中的最小 ...

  6. MATLAB中plot()函数的用法

    文章目录 前言 一.plot()函数 二.代码运行结果 总结 前言 此为本人学习中的一些笔记总结,仅供参考. 提示:以下是本篇文章正文内容,下面案例可供参考 一.plot()函数 提示:关于plot( ...

  7. matlab的filter函数,filter函数用法 matlab中filter函数的用法

    matlab中filter函数的用法如果你深爱的人此刻在你身边陪你,你怎么会有时间来看这些文字呢 离散系统的差分方程为 2y[k]-y[-1]-3y[k-2]=2x[k]-x[k-1] x[k]=(0 ...

  8. matlab中reshape函数的用法

    matlab中reshape函数的用法 1.函数功能:变换矩阵维度 2.转换规律:按列读,按列存 A =[1, 2, 3, 4;5, 6, 7, 8;9, 10, 11, 12 ];C = resha ...

  9. matlab中 repmat 函数的用法

    一.repmat 函数定义 B = repmat(A,n) B = repmat(A,r1,-,rN) B = repmat(A,r) 这是一个处理矩阵内容有重复时使用,其功能是以A的内容堆叠在(r1 ...

  10. Matlab中 linprog函数的用法总结

    转载,原文链接:https://www.cnblogs.com/goodtwo/p/11141969.html Matlab中 linprog函数的用法总结 1.简介 在matlab中,linprog ...

最新文章

  1. JS中相等运算符 == 隐式转换
  2. 红黑树(一)之 原理和算法详细介绍---转帖
  3. SQL中 不等于时存在null的问题
  4. 四面阿里,看看你都会吗
  5. C语言中float,double类型,在内存中的结构(存储方式).
  6. 编写一个程序,找出数组中元素的最大值,要求用到成员函数。
  7. 4.3串的模式匹配算法(BF算法)
  8. c语言经典程序100txt例,C语言经典程序100例txt格式.doc
  9. NPOI 操作EXCEL 小计
  10. java static final关键字_Java的static与final关键字
  11. mysql sql查询json数据类型_SQL中的JSON数据类型
  12. python 生成器 原理_你知道python中的函数、生成器的工作原理吗?
  13. 谁都会做:简单易行的祛斑法 - 生活至上,美容至尚!
  14. VS2008使用技巧及快捷键大全
  15. 虚拟机Linux终端命令格式
  16. k8s serviceAccountName填写后应用没有进行挂载问题处理
  17. Spark 连接kafka报错: Error while fetching metadata with correlation id xx [topicName=INVALID_REPLICATIO]
  18. 保时捷狂推NFT,高调喊出打造Web3社区,Web2品牌“天生缺陷”终将折戟沉沙?...
  19. 2023年了,推荐 5 款 API 管理工具
  20. 小米2+android版本,小米2/2S Android 4.4.2刷机详细教程

热门文章

  1. 公司游玩出行最美的去处,收获满满的华创
  2. DFS走迷宫(懒猫老师C++完整版)
  3. 计算机创造奇迹的英语作文,大学英语作文:创造奇迹-Creating-Miracle.docx
  4. 深光标准技术:谷歌GMS认证是什么?谷歌AER认证是什么?GMS认证的费用跟周期是多少??
  5. python第五章课后答案汉诺塔_python 习题
  6. 百兆宽带插网线只有1mb/s的下载速度问题!
  7. aio-pika的使用
  8. win10怎么设置开机启动项目_开机启动项怎么设置呢?
  9. mysql 木马_通过mysql写入一句话木马
  10. echarts 柱状图圆柱_使用echarts画柱状图