フィルターのクリア

How to access struct fields within cell array?

33 ビュー (過去 30 日間)
Payjay
Payjay 2017 年 7 月 30 日
回答済み: Akira Agata 2018 年 7 月 10 日
Hello there, I have a 50*1 cell array and every cell-element is a 100*1 cell-array, whose elements are from type struct. And I want to have the field values. I have tried something like this:
X = cell(length, 1)
for i
for j
X{i}{j} = Bigcellarray{i}{j}.field
end
end
This does not work, has anybody an idea? Greetings!
  2 件のコメント
James Tursa
James Tursa 2017 年 7 月 30 日
編集済み: James Tursa 2017 年 7 月 30 日
This is unclear. Are you trying to build such a cell array from variables you already have? If so, can you provide us exactly with what variables you have (class and size) to start with?
KSSV
KSSV 2017 年 7 月 31 日
To write a code for that.....we should know the structure perfect. Attach your data as .mat file, so that you can get a help.

サインインしてコメントする。

回答 (2 件)

Akira Agata
Akira Agata 2018 年 7 月 10 日
Then, how about the following? After running this, A is 100-by-50 numeric array where A(i,j) = Bigcellarray{i}{j}.field
C = [Bigcellarray{:}];
A = cellfun(@(x) x.field, C)';

Walter Roberson
Walter Roberson 2017 年 7 月 31 日
N = length(Bigcellarray);
X = cell(N, 1);
for i = 1 : N
for j = 1 : length(Bigcellarray{i})
X{i}{j} = Bigcellarray{i}{j}.field
end
end
  1 件のコメント
Eyshika Agarwal
Eyshika Agarwal 2018 年 7 月 9 日
it would be better to see without loop

サインインしてコメントする。

カテゴリ

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