GUI Has Error Although It Worked Fine Before and I Did Not Change Code

6 views (last 30 days)
Hi, when I first created my GUI everything worked fine. Then I closed Matlab, reopened my GUI and ran it and now it won't run because it has errors in its internal function when it worked fine before. I did not change anything in my code so I don't understand why it's no longer working when I reopen Matlab. I attached my code below. This is the error message I receive:
Undefined function or variable 'writePWMDutyCycle'.
Error in code1>pushbutton1_Callback (line 98)
writePWMDutyCycle(a,'D10',0);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in code1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)code1('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
This is my first time posting so please let me know if I need to clarify anything or change my formatting.
  6 Comments
L
L on 1 Sep 2017
Edited: L on 1 Sep 2017
I remade code1.m from scratch and named it code2.m. code2.m has the exact same code as code1.m
And in command window, I ran the two files and entered "which -all writePWMDutyCycle" and "path()". The attached pdfs are the results.
before_error.pdf is for code2.m and after_error.pdf is code1.m.
____________________________________________________________
EDIT/UPDATE:
I used excel to compare both results for path() and there were no differences.
Results for "which -all writePWMDutyCycle"
  • Before:
>> which -all writePWMDutyCycle
C:
\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\ardui
noio\@arduino\arduino.m % arduino method
C:
\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\ardui
noio\+arduinoio\+internal\MWProtocol.m % arduinoio.internal.MWProtocol method
C:
\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\ardui
noio\+arduinoio\+internal\ProtocolBase.m % arduinoio.internal.ProtocolBase method
  • After:
>> which -all writePWMDutyCycle
'writePWMDutyCycle' not found.
@Donald Lee: I missed your comment so I will try that now
Walter Roberson
Walter Roberson on 2 Sep 2017
Edited: Walter Roberson on 2 Sep 2017
To confirm: after the problem occurs, does
C:\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\arduinoio\@arduino\arduino.m
still exist?
If you execute the command
clear all
and run again, does it start working? How about if you
rehash toolboxcache
then does that start it working?
Another thing to try is
fclose('all')
when the problem has occurred.
It is certainly an odd situation.

Sign in to comment.

Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!