フィルターのクリア

Get size of each element in a cell

118 ビュー (過去 30 日間)
Marcio Teixeira
Marcio Teixeira 2020 年 9 月 7 日
編集済み: the cyclist 2020 年 9 月 7 日
Hello there,
I would like to know if it is possible to get the number of elements in a given cell by "indexing".
I did a short workaround like this:
%create some random data
myCell = {rand(100,3),rand(220,5),rand(1111,4), ["Mercury","Gemini","Apollo";
"Skylab","Skylab B","ISS"]};
% getting required information using a loop
for i=1:4
size(myCell{i})
end
The output will be as follows:
ans = 100 3
ans = 220 5
ans = 1111 4
ans = 2 3
solving the probelm. What I am asking is if I can do something more elegant such as:
size(myCell{1:4})
instead of using the for loop. If I try above statement the error message is:
Error using size
Dimension argument must be a positive integer scalar within indexing range
Thank you!

採用された回答

the cyclist
the cyclist 2020 年 9 月 7 日
編集済み: the cyclist 2020 年 9 月 7 日
You can use the cellfun command:
cellfun(@size,myCell,'UniformOutput',false)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by