Number of elements in cell array

9 次查看(过去 30 天)
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 个评论
Mathieu NOE
Mathieu NOE 2021-3-12
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

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by