Trying to make a scientific calculator GUI and get this type of error message for all numbers but '6'. 6 is my first pushbutton. Any assistance would be appreciated.
Show older comments
Undefined function or variable 'textString'.
Error in calc>pushbutton2_Callback (line 164) if(strcmp(textString,'0')==1)&(jj==0);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in calc (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)calc('pushbutton2_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback
Answers (2)
Image Analyst
on 19 Oct 2015
0 votes
Why do you think textString should be defined by the time it gets to that line of code? Did you call get() in that function to extract it from an edit field?
By the way, you should also use && instead of &, and you don't need ==1 when comparing to strcmp() since strcmp() returns a boolean.
3 Comments
Bob Riggin
on 19 Oct 2015
Image Analyst
on 19 Oct 2015
Does the callback function for push button 6 look any different than the functions for buttons 0-5 and 7-9?
Bob Riggin
on 19 Oct 2015
Walter Roberson
on 19 Oct 2015
If you are trying to detect whether the pushbutton is pushed or not then
if get(hObject, 'Value') == 1
%pushbutton is pressed
end
Note: pushbutton callbacks are not normally called when the button is released, so unless you are doing something unusual, you can assume that the current button is pressed.
6 Comments
Bob Riggin
on 19 Oct 2015
Walter Roberson
on 19 Oct 2015
We already established that the error is not on line 58, so it must be on line 57 instead. We know that because we are all psychic and can read your screen by using the secret MATLAB Z-Rays Toolbox.
Bob Riggin
on 19 Oct 2015
Image Analyst
on 19 Oct 2015
Attach your fig file and .m file with the paper clip icon.
Bob Riggin
on 19 Oct 2015
Bob Riggin
on 19 Oct 2015
Edited: Walter Roberson
on 20 Oct 2015
Categories
Find more on Call Java from MATLAB 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!