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.