ディレクトリの指定方法
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hiroki Takeda
am 14 Mai 2022
Kommentiert: Hiroki Takeda
am 15 Mai 2022
rawdataのディレクトリの中に、データ1,データ2,データ3...のように複数入っています。
また、データ1,データ2,データ3...の中には、2021, 2020, 2019...のような、年ごとのデータが入っています。
ディレクトリを一つずつ指定しながら、そのディレクトリ内部のデータ処理を検討しています。
ディレクトリの指定には、以下のようなイメージのことを行いたいですが、うまくいっておりません。
rootname='データ1';
yearname='2021';
% Dataの抽出
F_name=dir('/Users/id/Desktop/data/size_data/rawdata/'rootname'/'yearname'/*.xlsx');
この辺り、ご教示くださりますと幸いです。
どうぞよろしくお願いいたします。
0 Kommentare
Akzeptierte Antwort
Hernia Baby
am 14 Mai 2022
Bearbeitet: Hernia Baby
am 14 Mai 2022
fullfile で連結させましょう
データ群を用意します。
rootname = ("データ"+string(1:10))';
yearname = string((2021:-1:2000)');
中身を少し見てみましょうか
rootname(1:3)
さてパスと拡張子をくっつけます
path = '/Users/id/Desktop/data/size_data/rawdata/';
Files = '*.xlsx';
for ii = 1:3
for jj = 1:3
Filenames = fullfile(path,rootname(ii),yearname(jj),Files)
% F_name = dir(Filenames);
end
end
Weitere Antworten (1)
Atsushi Ueno
am 14 Mai 2022
rootname='データ1';
yearname='2021';
F_name=dir(['/Users/id/Desktop/data/size_data/rawdata/' rootname '/' yearname '/*.xlsx']);
0 Kommentare
Siehe auch
Kategorien
Mehr zu ファイルの操作 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!