How to load a txt file and save the workspace

7 ビュー (過去 30 日間)
영우
영우 2023 年 9 月 22 日
コメント済み: 영우 2023 年 9 月 23 日
I have txt files numbered like data_1, data_2, data_3 data_4..
And I want to load these files into workspace named 1, 2,3,4. How should I write the code?

回答 (1 件)

Mathieu NOE
Mathieu NOE 2023 年 9 月 22 日
you can create a structure D where all informations are stored (filenames and data)
D = dir('*.txt'); % D is a structure array
for k = 1:numel(D)
D(k).data = readmatrix(D(k).name);
end

カテゴリ

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