Azzera filtri
Azzera filtri

Number of elements in cell array

9 visualizzazioni (ultimi 30 giorni)
Ishan Gawai
Ishan Gawai il 12 Mar 2021
Commentato: Ishan Gawai il 13 Mar 2021
Consider following code and I want find total number of elements in a. I want the answer to be 17.
a = {2};
a(2) = {magic(4)};
  1 Commento
Mathieu NOE
Mathieu NOE il 12 Mar 2021
yes
total number of a array is 17
a{:}
ans =
2
ans =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1

Accedi per commentare.

Risposta accettata

Balazs Fischer
Balazs Fischer il 12 Mar 2021
sum(cellfun('prodofsize',a))
it gets more complicated when a contains other cell arrays.

Più risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by