[初学笔记] meshgrid 和 size

1 meshgrid


X,Y] = meshgrid(x,y) 将向量x和y定义的区域转换成矩阵X和Y,这两个矩阵可以用来表示mesh和surf的三维空间点以及两个变量的赋值。其中矩阵X的行向量是向量x的简单复制,而矩阵Y的列向量是向量y的简单复制。Generate X and Y matrices for three-dimensional plots


X,Y] = meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y.
[X,Y] = meshgrid(x) is the same as [X,Y] = meshgrid(x,x).
[X,Y,Z] = meshgrid(x,y,z) produces three-dimensional arrays used to evaluate functions of three variables and three-dimensional volumetric plots


>> a = [11 12 13];
b = [21 22 23;24 25 26; 27 28 29];
e = [3 4 5]
[k,j] = meshgrid (a,e)
[f,r] = meshgrid (e,a)
[c,d] = meshgrid (b(3,:),a)
e =
     3     4     5

k =
    11    12    13
    11    12    13
    11    12    13

j =
     3     3     3
     4     4     4
     5     5     5

f =
     3     4     5
     3     4     5
     3     4     5

r =
    11    11    11
    12    12    12
    13    13    13

c =
    27    28    29
    27    28    29
    27    28    29

d =
    11    11    11
    12    12    12
    13    13    13


2 size

size(A)函数是用来求矩阵的大小的,你必须首先弄清楚A到底是什么,大小是多少。

>> a = [11 12 13];
>> size (a)
ans =
     1     3

>> b = [1:3;4:6;7:9];size(b)
ans =
     3     3


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值