필터 지우기
필터 지우기

Add same to different paths

조회 수: 1 (최근 30일)
Priya
Priya 2013년 6월 11일
I have a folder, which has some excel sheets. These excel sheets are taken as input for my code.
I am using cd and addpath and rmpath functiions to automatically run this script in different folders.
I need to run this code in 5 different folders. Input files in folders are same. There are around 800 input files. I dont want to copy paste these files in all 5 folders.
Is there any way by which I could call the files from one folder as input in all 5 different folders while running code.
I tried using shortcuts , but it did not work.

채택된 답변

Jan
Jan 2013년 6월 11일
편집: Jan 2013년 6월 11일
You can address a file using the full path:
Folder = 'C:\DataPath'; % Set accordingly
List = dir(fullfile(Folder, '*.xlsx');
for iList = 1:length(List)
File = fullfile(Folder, List(iList).name);
... Operations with the file here
end
Now accessing the files is independent from th current folder.
  댓글 수: 7
Jan
Jan 2013년 6월 12일
@Priya: I still do not understand, why you have to copy the files or why they must be found in the current folder. I have shown you already, how you can access a file in a specific folder using the folder's name and the fullfile() command. Please explain why you do not want to use the full path name to the files.
And of course yo do not have to use a FOR loop. It appears in my example code only as example. The main point is the fullfile().
Priya
Priya 2013년 6월 12일
@Jan and @lain :Thanks, I combined both suggestions and it worked

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by