Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Strange Undefined variable or control error for a function

1 vue (au cours des 30 derniers jours)
Jack
Jack le 17 Déc 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
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
Jack

Réponses (1)

Thorsten
Thorsten le 17 Déc 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 commentaire
Jack
Jack le 17 Déc 2014
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

Community Treasure Hunt

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

Start Hunting!

Translated by