How to navigate between directories during program execution?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
per isakson
il 15 Set 2017
Modificato: per isakson
il 15 Set 2017
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.
Risposte (1)
Honglei Chen
il 7 Lug 2011
Hi Yashar,
The following command may be of your interest
doc run
doc fullfile
HTH
1 Commento
Vedere anche
Categorie
Scopri di più su Search Path in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!