How to calculate the number of elements in a matrix?

33 次查看(过去 30 天)
e.g having this matrix: M=[ 1 2 3; 7 8 9] I want to return 6 which is the total number of elements I want some other method besides size(M,1)*size(M,2). Thx

采纳的回答

Image Analyst
Image Analyst 2016-1-9
Use numel():
numberOfElements = numel(M);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by