Effacer les filtres
Effacer les filtres

How to calculate the number of elements in a matrix?

33 vues (au cours des 30 derniers jours)
Nicoleta
Nicoleta le 9 Jan 2016
Commenté : Pravin Narola le 19 Juil 2019
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

Réponse acceptée

Image Analyst
Image Analyst le 9 Jan 2016
Use numel():
numberOfElements = numel(M);

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by