MATLAB:UndefinedFunction error, even when file is found on path

I have an .m file that I would like to run called bacteria2, however, I can't seem to convince MATLAB (R2016a, OSX 10.11) to run it. When I attempt to execute
bacteria2();
This results in the error message
Undefined function or variable 'bacteria2'.
In case it helps to know which error code is being triggered, the error id from
[errMsg,errId] = lasterr
is
MATLAB:UndefinedFunction
However, attempting to open the program in the editor from the command line works fine. That is,
edit('bacteria2')
opens the correct copy of 'bacteria2' in my Dropbox folder for editing. The issue seems to be something to do with the fact that there are odd characters in the path.
which('bacteria2','-all');
Gives an output of
/Users/benbratton/Dropbox/Alex L <> Ben B/bacteria2.m
Another symptom of this path issue is the inability to enable breakpoints in the file. Once the file is open in the editor, any attempt to enable a breakpoint in the editor results in the following error message
My workaround is to move the file to a different location and then manually copy it over to dropbox when I want to share changes with my collaborator. It would be great to have a better solution.

2 comentarios

I can't help about your issue, there certainly is some characters that have special meaning in the path (@ and +) but as far as I know < and > are ok.
However, I would like to point out that a much better and safer way of sharing changes with collaborators is to use a version control system. Not only do they track changes but these have diff and merge tools to show you exactly what has changed and handle conflicting changes. Matlab has built-in support for git and subversion.
Thanks! I agree that SVN/git are great tools for version tracking and managing conflicts. In addition, I find it really convenient to be able to switch between feature sets by simply checking out a different branch. We decided on Dropbox for this particular situation because not all of my coworkers are willing to make the jump to git.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 1 de Nov. de 2016
lasterr does not change until you either overwrite it or a new error occurs. You have not shown us bacteria2 failing: what you show is the possibility that it worked fine but lasterr had happened to be set to that before bacteria2 was run.
You should also consider the possibility that MATLAB is not able to access the file directly off of Dropbox . You might need to copy the file locally.

3 comentarios

Thanks, I have updated the question to more clearly reflect what is happening, it is indeed 'bacteria2' that is failing.
Would you be able to clarify more about the idea that MATLAB is not able to access the file directly off of Dropbox? The directory is "local' in the sense that the files exist on my computer. I can take the Dropbox client offline or turn off my connection to the Internet and the file still exists in the same state. I'm able to edit the file from within the MATLAB editor and save those changes back to the file, so I think that MATLAB can access the file.
I have had difficulty in the past in which files in my Dropbox or Google Drive could not be fully accessed while they were there. I did not try to debug the problem, as it was much the same problem as used to occur with NFS and NFSv2 servers, race conditions, and some ioctl()'s. Networked file systems are hard to do right.
Thanks for the tip, unfortunately my error does not seem to be Dropbox related. I made new fictitious directories containing "<", "<>", "><" and ">". All folders including ">" in the path result in this error. The folder with only a "<" was perfectly acceptable to MATLAB's parser.

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 1 de Nov. de 2016

Comentada:

el 10 de Nov. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by