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

3 views (last 30 days)
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 Comments
Guillaume
Guillaume on 1 Nov 2016
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.
Benjamin Bratton
Benjamin Bratton on 1 Nov 2016
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.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 1 Nov 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 Comments
Walter Roberson
Walter Roberson on 2 Nov 2016
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.
Benjamin Bratton
Benjamin Bratton on 10 Nov 2016
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.

Sign in to comment.

Categories

Find more on Source Control Integration in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!