필터 지우기
필터 지우기

How to use files from different folders to the script.

조회 수: 1 (최근 30일)
James hall
James hall 2012년 8월 22일
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'))

채택된 답변

Titus Edelhofer
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
James hall
James hall 2012년 8월 31일
Hi
Sorry for the late reply, when it comes to executing the file is there a way to choose a range, so if a drop box says choose date, you would be able to enter a range such as
01/08/2012-07/08/2012
Titus Edelhofer
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
Image Analyst 2012년 8월 31일
편집: Image Analyst 2012년 8월 31일
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.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by