Problem locating function file
Mostra commenti meno recenti
I created a function using an existing function in the stats toolbox. In particular, I just made a few tweeks and saved the modification using a different function name. First, I saved it in my working directory and Matlab could not find it (yes I used the same spelling). Then, I saved it in the stats toolbox directory and Matlab did find the function when using the 2007a version but not when using the 2008b or 2009b versions. And yes, I have set the path to this directory and have no problems calling other functions in the toolbox in any of the versions.
Any ideas on why this is happening?
Risposte (2)
Walter Roberson
il 15 Ott 2011
0 voti
You should never store your own function in one of the toolbox directories, in any version.
It is not a good practice to name your own function the same as an existing MATLAB function: if you do that and your own function is earlier on the path than the existing function, then even Mathwork's own routines will call the one you created, which can lead to obscure problems.
You should also explore the "rehash" command.
1 Commento
Mike
il 16 Ott 2011
Jan
il 15 Ott 2011
0 voti
The toolbox folders are included in the path in 'freezed' mode (see: help addpath), such that new files in these folders are recognized after rehash toolboxreset only.
Therefore it is strongly suggested not to write into the toolbox paths. Create a user-defined folder and include it in the path. Crae for a function name, which does not conflict with names of a toolbox function.
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!