How to Open all of .mat file in one folder?

20 ビュー (過去 30 日間)
Jingqi Sun
Jingqi Sun 2022 年 12 月 2 日
コメント済み: Jingqi Sun 2022 年 12 月 2 日
Hello, I have some .mat files in a folder, I want to import them all to matlab. I tried to double click each file, however by clicking each file I could only import a variable called : 'ModulatedPulse' . Each time I click another file it will just import another ModulatedPulse and overwrite the origional one.
Why do I keep having this ModulatedPulse variable? What should I do to import all of .mat files at the same time? The names for these files are numbers, for example: "36.mat".
Thank you.
  1 件のコメント
Stephen23
Stephen23 2022 年 12 月 2 日
編集済み: Stephen23 2022 年 12 月 2 日
"Why do I keep having this ModulatedPulse variable?"
Because that is what your MAT files contain. What do you expect them to contain?
"What should I do to import all of .mat files at the same time?"

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

採用された回答

Stephen23
Stephen23 2022 年 12 月 2 日
編集済み: Stephen23 2022 年 12 月 2 日
P = 'absolute or relative path to the folder where the files are saved';
S = dir(fullfile(P,'*.mat'));
for k = 1:numel(S)
F = fullfile(P,S(k).name);
T = load(F);
S(k).ModP = T.ModulatedPulse;
end
The file data are in the structure S which you can access easily using indexing. For example the 2nd file:
S(2).name % filename
S(2).ModP % imported file data
  1 件のコメント
Jingqi Sun
Jingqi Sun 2022 年 12 月 2 日
Thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by