How to use files from different folders to the script.
3 ビュー (過去 30 日間)
古いコメントを表示
Hi guys
my files are organised as such:
Engine\Vehicle\Date\data.csv
files for each vehicle are organised into days.
I want to be able to run my script from one location without having to copy it into each folder that I want to use it. This is for data analysis so the file names and subfolder names change regularly each day. the folder name stays the same however.
The script that I use lives in a different directory.
Currently I have been able to add the files to the script path with
addpath(genpath('Engine'))
0 件のコメント
採用された回答
Titus Edelhofer
2012 年 8 月 22 日
Hi,
what about the following procedure:
theDates = dir('.\Engine\Vehicle');
for iDate = 1:length(theDates)
if theDates(i).isdir
data = csvread(fullfile(pwd, 'Engine', theDates(iDate).name, 'data.csv'));
end
end
2 件のコメント
Titus Edelhofer
2012 年 8 月 31 日
Hi,
you could do something like
startDate = datenum('01/08/2012');
endDate = datenum('07/07/2012');
theDateNums = datenum({theDates.name});
% now choose:
idx = theDateNums>=startDate & theDateNums<=endDate;
theDates = theDates(idx);
% continue processing all files of theDates
Titus
その他の回答 (1 件)
Image Analyst
2012 年 8 月 31 日
編集済み: Image Analyst
2012 年 8 月 31 日
Several examples are in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
If you want to interactively select files based on the date, use uigetfile() and then you use the icon in the dialog box to show details, one of which will be the date. You can also sort them there.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!