Model Portability - Troubleshooting Directory Path Error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello.
I have a MATLAB model that runs only if my current working directory is set to its saved file path. I should note that the model calls a bunch of external files (both MATLAB custom functions and files completely unrelated to MATLAB), all contained within the same folder. I'd like to correct this problem, allowing me to just copy and paste all the folder in whatever other directory, or computer for that matter, and still be able to run the program. What kinds of commands would you guys suggest I investigate? That would be really a great help.
Thank you.
0 comentarios
Respuestas (3)
Joseph Cheng
el 7 de Oct. de 2015
Editada: Joseph Cheng
el 7 de Oct. de 2015
You probably want to look at the following:
pwd %get current working directory
addpath %add a path to matlab's list of places to search function/files
genpath %get subfolders, don't really think you need this but there it is
cd %change working directory
%folder/file navigation
uigetfile/uiputfile/uigetdir..... etc %user inputs
fullfile() %combine folder and file path to a full path
so depending on what you mean by "working directory is set to its saved file path" you can build the working directory and specified folders based relative to the initial working directory and then the uigetfile/uiputfile/etc in conjunction with fullfile() lets you write to a specific folder location.
0 comentarios
Vicente
el 7 de Oct. de 2015
2 comentarios
Joseph Cheng
el 7 de Oct. de 2015
what is the error or warning or whatever is stopping you? Does this function look for the data files directly by itself (ie whatever folder it is in grabs all *.bin files for processing), do you pass file names to this function, or does this function have nothing to do with the data files and processes a matrix that you give it?
Ver también
Categorías
Más información sobre Search Path en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!