MATLAB Answers


Strange Undefined variable or control error for a function

Asked by Jack
on 17 Dec 2014
Latest activity Commented on by Jack
on 17 Dec 2014
Hi, I created a control file that calls on three separate functions to perform a task. They are all in a single directory. I copied and pasted all of these four files to a different directory to do something different and they work fine. However returning to the original directory, I try to run the code from the 'Control' file and I get an 'undefined variable or function 'control' ' error. I've tried renaming all of the files and it still doesn't work. They are all in the same directory as I have used 'which' to make sure everything is okay.
Does anyone have any insight into what to do here? I have made no changes to the actual code since copying and pasting.
Many Thanks


Sign in to comment.

1 Answer

Answer by Thorsten
on 17 Dec 2014

Have you double-checked that your control.m is seen by Matlab? What does
>> which control
shows before you type
>> control
and get the error?

  1 Comment

Thanks for this Thorsten. I did do this and they all appeared as being in the correct folder. Interestingly I cut and pasted the files into the main MATLAB directory and they worked fine. In fact if I copy and pasted them in any different folder they worked fine except when they were in the one they were originally in!
I've deleted that folder, created a new one and put them there and they work fine, bit of a pain but a solution. I'd love to know what the issue was though, so if you have any ideas let me know! Thanks, Jack

Sign in to comment.