How can I combine 100+ matrices into a combined array for indexing

1 回表示 (過去 30 日間)
ShaneS
ShaneS 2016 年 8 月 15 日
編集済み: ShaneS 2017 年 8 月 1 日
Hello MATLAB experts,
I have a bunch of matrices (82 x 82), one for each research subject. How can I combine these matrices into a single .mat file so I can extract information about the matrices with a command such as: combined_matrices(5) to get the 82 x 82 matrix for subject number 5?
Thanks very much.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 15 日
編集済み: Azzi Abdelmalek 2016 年 8 月 15 日
Use cell arrays
M={A1,A2,A3,A4,A5}
save filename M
To get the matrix for project N°5
A=M{5}
Since your matrices are same sizes, another alternative is to use a 3-D Matrix
M(:,:,1)=A1
M(:,:,2)=A2
.... % and so on
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 15 日
for k=1:10
file=sprintf('A%d',k)
A=load(file)
f=fieldnames(A)
M(:,:,k)=A.(f{1})
end
ShaneS
ShaneS 2016 年 8 月 15 日
Thank you so much, Azzi!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by