Files on path are inaccessible (sometimes)
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an .m file called staverify.m (the path is 'C:\Matlab\spike\demo'). I also have 'C:\Matlab' and all of its subfolders in the search path. When my current folder is set to 'C:\Matlab\spike\"anything"', where "anything" is any one of the subfolders of \spike (even empty folders), then I can run staverify without a problem. If my current folder is set to any other folder, though, then I get this error:
??? Error using ==> load Unable to read file ..\data\verify_expected: No such file or directory.
Error in ==> staverify at 10 eval(strrep('load ../data/verify_expected','/',filesep));
The verify_expected file is the first file staverify calls and is, in fact, in '\spike\data', which is on the search path. If I run 'which verify_expected.mat', it finds the file immediately. I get similar errors for other files, often with compiled mex files not being found but their .m counterparts being found. This is crippling my ability to run any of my programs.
None of these files are in the toolbox folders; I saw how common that error was, and double-checked. I haven't made any changes to the toolbox folders at all, except for saving the search path.
0 Kommentare
Antworten (3)
Walter Roberson
am 13 Mai 2011
When you specify a directory then (as far as I know), load() does not search along the search path, and instead assumes that the path is relative to the current directory if it is not an absolute path.
0 Kommentare
Leah
am 13 Mai 2011
I get this error sometimes when I am working on a server and have drives mapped differently. I don't think this is your issue since C: is probably your local drive.
Try adding the file extension or using addpath
Andrew Fooden
am 13 Mai 2011
3 Kommentare
Walter Roberson
am 13 Mai 2011
staverify and demo_metric making relative path references without first checking that those relative paths are valid. The problem is in their coding, not in MATLAB in general.
You appear to be using the third party Spike Train Analysis Toolkit from neuroanalysis.org
When you are in a subdirectory of spike\ then the ".." at the beginning of the paths means to look up one directory first, which would position it logically to the spike\ directory. Then the /data component of the path being requested would move it to the data directory relative to where it was, leaving it in spike\data\ after which the file references such as taste.stam work properly.
When you are in any other directory, going up one level relative to where you start will work, but then looking for a data\ directory relative to there will not generally work.
Your logical error is in expecting that MATLAB always searches along the search path trying to satisfy partial paths; however, when a partial path is given to MATLAB it does not do a search. The search is only done if no partial path is specified.
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!