Matlab中ones()用法
2013-04-08 17:33
246 查看
ONES Ones array.
ONES(N) is an N-by-N matrix of ones.
ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones.
ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by-... array of
ones.
ONES(SIZE(A)) is the same size as A and all ones.
ONES with no arguments is the scalar 1.
ONES(M,N,...,CLASSNAME) or ONES([M,N,...],CLASSNAME) is an M-by-N-by-...
array of ones of class CLASSNAME.
由此可以看出,ones的作用是产生全1矩阵,ones(N)是产生一个N*N的全1矩阵,如:
>> ones(3)
ans =
1 1 1
1 1 1
1 1 1
ones(M,N)产生一个M*N的矩阵,如
>> ones(3,4)
ans =
1 1 1 1
1 1 1 1
1 1 1 1
需要注意的是ones(size(A))的用法,size(A)返回的是A的大小参数,如果A是一个3X4的矩阵的话,则返回的参数应该是3 4,所以ones(size(A))产生的矩阵应该是与A大小相同的全1矩阵
ONES(N) is an N-by-N matrix of ones.
ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones.
ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by-... array of
ones.
ONES(SIZE(A)) is the same size as A and all ones.
ONES with no arguments is the scalar 1.
ONES(M,N,...,CLASSNAME) or ONES([M,N,...],CLASSNAME) is an M-by-N-by-...
array of ones of class CLASSNAME.
由此可以看出,ones的作用是产生全1矩阵,ones(N)是产生一个N*N的全1矩阵,如:
>> ones(3)
ans =
1 1 1
1 1 1
1 1 1
ones(M,N)产生一个M*N的矩阵,如
>> ones(3,4)
ans =
1 1 1 1
1 1 1 1
1 1 1 1
需要注意的是ones(size(A))的用法,size(A)返回的是A的大小参数,如果A是一个3X4的矩阵的话,则返回的参数应该是3 4,所以ones(size(A))产生的矩阵应该是与A大小相同的全1矩阵
相关文章推荐
- matlab 中ones、zeros和prod函数的用法
- matlab中zeros 和 ones 这两个函数的用法以及size的用法,princomp,pcacov,pcares,barttest四大分析函数用法
- Matlab [] {} () 大小中括号的用法
- matlab中meshgrid函数的用法
- matlab中图像处理常见用法
- MATLAB关于文件操作的一些基本用法
- matlab:eval用法
- matlab的基本用法
- matlab中 fprintf 和disp的用法
- Matlab的imfilter函数用法详解
- Matlab中fscanf的用法
- matlab中repmat函数的用法
- matlab中feval函数的用法
- matlab中clear的用法
- matlab 中norm函数的用法
- MATLAB中stem函数用法
- Matlab中fft函数的用法及关键问题详解
- matlab中svd函数用法总结
- Matlab中imhist的用法
- matlab的rand()函数产生均匀分布函数的正确用法 / matlab 中如何产生0-1上均匀分布的随机数