Using load for different files with varying names

5 ビュー (過去 30 日間)
Miraboreasu
Miraboreasu 2022 年 9 月 13 日
編集済み: Stephen23 2022 年 9 月 14 日
I have 25 files with .mat files, naming from data1 to data25
how to load them properly without manualy typing from 1 to 25
Here is my idea and the error
```
for i = 1:1:25
load('data%d.mat',i)
end
```
Error using load
Must be a text scalar.

採用された回答

Akira Agata
Akira Agata 2022 年 9 月 13 日
How about the following?
for kk = 1:25
fileName = sprintf('data%d.mat', kk);
load(fileName)
%
% Some process for each file
%
end
  2 件のコメント
Akira Agata
Akira Agata 2022 年 9 月 14 日
Yes, of course it is recommended to load into an output variable, as you mentioned.
Thank you for your additional comment !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by