creating a single structure with 100 entries

2 ビュー (過去 30 日間)
John
John 2012 年 2 月 19 日
Hello,
I was hoping that perhaps somebody could help me out with a problem that I have.
I have imported 100 4x4 matrices into a cell array using the code below.
C = cell(100,1);
for ii = 1:100
C{ii} = importdata(['matrix' num2str(ii) '.txt']) ;
end
I am wondering how would I create a structure with 100 entries and place a matrix in each entry.
The reason I ask is because I'm trying to get the average of these matrices and this post provides a solution if the matrices are in this format.
Thank you for your help
Regards
John

採用された回答

Jiro Doke
Jiro Doke 2012 年 2 月 19 日
You don't need to create a structure for that. You can do this:
C2 = cat(3, C{:});
avg = mean(C2, 3)
FYI, to answer your original question, the function is cell2struct.
  1 件のコメント
John
John 2012 年 2 月 19 日
Brilliant, thanks very much!

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

その他の回答 (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