matlab 函数

 

 

size(a,1)求矩阵的行数
size(a,2)求矩阵的列数,相当于length(a)
size(a)同时求矩阵的行和列数

size(a,n)取矩阵a的第n维

 

示例一

>> a = [1 2 3; 4 5 6];

>> [m, n] = size(a)

m = 2, n = 3

示例二

>> a = [1 2 3; 4 5 6];

>> b = [4 5 6; 7 8 9];

>> d = zeros(2, 3, 2);

>> d(:, :, 1) = a;

>> d(:, :, 2) = b;

>> [m n p] = size(d)

m = 2, n = 3, p = 2

由此可见d是一个2×3×2的三维数组(这里我们也可以用reshape函数或者cat函数或者使用for循环来构建三维数组)。

>> [m n] = size(d)

m = 2,n = 6

这里m指出了第一维的长度, 而这里的n就等于剩下两维长度的乘积,即6。

>> m = size(d)

m = 2 3 2

示例三

>> [m n p q] = size(a)

m = 2, n = 3, p = 1, q = 1

转自360百科及其他参考

 

Resize image

Syntax

B = imresize(A, scale)
B = imresize(A, [mrows ncols])
[Y newmap] = imresize(X, map, scale)
[...] = imresize(..., method)
[...] = imresize(..., parameter, value,...)

Description

B = imresize(A, scale) returnsimage B that is scale timesthe size of A. The input image A canbe a grayscale, RGB, or binary image. If scale isbetween 0 and 1.0, B is smaller than A.If scale is greater than 1.0, B islarger than A.

B = imresize(A, [mrows ncols]) returnsimage B that has the number of rows and columnsspecified by [mrows ncols]. Either NUMROWS or NUMCOLS maybe NaN, in which case imresize computesthe number of rows or columns automatically to preserve the imageaspect ratio.

[Y newmap] = imresize(X, map, scale) resizesthe indexed image X. scale caneither be a numeric scale factor or a vector that specifies the sizeof the output image ([numrows numcols]). By default, imresize returnsa new, optimized colormap (newmap) with the resizedimage. To return a colormap that is the same as the original colormap,use the 'Colormap' parameter (see below).

[...] = imresize(..., method) resizesthe indexed image. method can be (1) atext string that specifies a general interpolation method, (2) a textstring that specifies an interpolation kernel, or (3) a two-elementcell array that specifies an interpolation kernel.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值