How to navigate between directories during program execution?
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a program in which I need to navigate from directory to directory (with the number of such directories being a variable), and read a bunch of files and execute a bunch of function files in them. Part of the reason they are put in different directories is that the M-files in these directories have the same names. My question is how:
- without changing the current directory (using the cd command)and
- without adding and removing paths with addpath and rmpath
Can I access these files selectively without creating conflict. Meaning every single time inside the program when I want to execute a function or read a file I could just do it knowing the full path of that folder. So all there would be known to you at each time is the full directories of the folders where these files are located.
One last note: Although I said the number of such directories is a variable, I know exactly which level they are located at, equivalently I know their full path every time at that juncture in my program (If this helps further ==> great, otherwise ==> ignore this last comment).
Thank you
댓글 수: 3
per isakson
2017년 9월 15일
편집: per isakson
2017년 9월 15일
For some reason this question appeared as Most Recent.
AFAIK: "[...] I want to execute a function [...] I could just do it knowing the full path of that folder" That is not possible, not without manipulating the search path or the current directory.
Had it been package folders it might be possible. Given
...\folder_in_the_search_path\+mypack\+mysubpack\myFcn.m
this call is possible
out = mypack.('mysubpack').myFcn( inarg )
However, I fail to find support in the documentation.
답변 (1개)
Honglei Chen
2011년 7월 7일
Hi Yashar,
The following command may be of your interest
doc run
doc fullfile
HTH
참고 항목
카테고리
Help Center 및 File Exchange에서 Search Path에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!