曹冲txt:MATLAB中 求矩阵元素个数的方法

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 00:35:00

例如 x=[0 1 2;3 4 5],求x中元素总个数

法1:a=numel(x);----------->a=6

法2 :b=prod(size(x));------>> b=6

PS:

1.size:获取数组的行数和列数,eg:size(x)=[2   3]

2.prod: Product (乘积)of elements.PROD(X,DIM) works along the dimension DIM.