Mode of table sizes within a structure

3 ビュー (過去 30 日間)
Will Kinsman
Will Kinsman 2016 年 5 月 11 日
回答済み: Will Kinsman 2016 年 5 月 12 日
I have a structure we will call 'structure'. it has tables in it of varying sizes. i want to find the mode of the table sizes within the structure. what is the easiest and fastest way to do this??
i.e. GIVEN structure: structure.A = 1000x10 table structure.B = 9998x10 table structure.C = 1000x10 table structure.D = 1001x10 table
OUTPUT = 1000;
Thank you so much to any help in advance.
%At first attempt, I would build a for loop such that
tablesizes = zeros(numel(structure),1)
for i = 1:numel(structure)
tablesizes(i) = size(structure.(i),1);
end
output = mode(tablesizes);

採用された回答

Will Kinsman
Will Kinsman 2016 年 5 月 12 日
With a little modification the above solution worked with acceptable speed

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by