Error while evaluating UIControl Callback
10 次查看(过去 30 天)
显示 更早的评论
the code was written in guide whatever push putton i use i get the same error i would apprechiate any help please THE ERROR { Reference to non-existent field 'text1'.
Error in cal>Zero_Callback (line 266) OLDstring=get(handles.text1,'string');
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in cal (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)cal('Zero_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback } THE FULL CODE:
function varargout = cal(varargin) % CAL MATLAB code for cal.fig % CAL, by itself, creates a new CAL or raises the existing % singleton*. % % H = CAL returns the handle to a new CAL or the handle to % the existing singleton*. % % CAL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in CAL.M with the given input arguments. % % CAL('Property','Value',...) creates a new CAL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before cal_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to cal_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help cal
% Last Modified by GUIDE v2.5 01-May-2018 15:45:23
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @cal_OpeningFcn, ... 'gui_OutputFcn', @cal_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end
if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT
% --- Executes just before cal is made visible. function cal_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to cal (see VARARGIN)
% Choose default command line output for cal handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes cal wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = cal_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure varargout{1} = handles.output;
% --- Executes on button press in Two. function Two_Callback(hObject, eventdata, handles) % hObject handle to Two (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('2'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Six. function Six_Callback(hObject, eventdata, handles) % hObject handle to Six (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('6'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in multiplication. function multiplication_Callback(hObject, eventdata, handles) % hObject handle to multiplication (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('*'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Power. function Power_Callback(hObject, eventdata, handles) % hObject handle to Power (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('^'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Tan. function Tan_Callback(hObject, eventdata, handles) % hObject handle to Tan (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) textstring=get(handles.text1,'string'); textstring=strcat(textstring,'tan(pi/180*'); set(handles.text1,'string',textstring);
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=(')'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Three. function Three_Callback(hObject, eventdata, handles) % hObject handle to Three (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('3'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Point. function Point_Callback(hObject, eventdata, handles) % hObject handle to Point (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('.'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Seven. function Seven_Callback(hObject, eventdata, handles) % hObject handle to Seven (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('7'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in division. function division_Callback(hObject, eventdata, handles) % hObject handle to division (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('/'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in pushbutton14. function pushbutton14_Callback(hObject, eventdata, handles) % hObject handle to pushbutton14 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in Clear. function Clear_Callback(hObject, eventdata, handles) % hObject handle to Clear (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
set(handles.text1,'string','');
% --- Executes on button press in One. function One_Callback(hObject, eventdata, handles) % hObject handle to One (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('1'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Five. function Five_Callback(hObject, eventdata, handles) % hObject handle to Five (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('5'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Nine. function Nine_Callback(hObject, eventdata, handles) % hObject handle to Nine (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('9'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Subtraction. function Subtraction_Callback(hObject, eventdata, handles) % hObject handle to Subtraction (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('-'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Cosine. function Cosine_Callback(hObject, eventdata, handles) % hObject handle to Cosine (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) textstring=get(handles.text1,'string'); textstring=strcat(textstring,'cos(pi/180*'); set(handles.text1,'string',textstring);
% --- Executes on button press in pushbutton0. function pushbutton0_Callback(hObject, eventdata, handles) % hObject handle to pushbutton0 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('('); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Zero. function Zero_Callback(hObject, eventdata, handles) % hObject handle to Zero (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('0'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Four. function Four_Callback(hObject, eventdata, handles) % hObject handle to Four (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('4'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Eight. function Eight_Callback(hObject, eventdata, handles) % hObject handle to Eight (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('8'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Addition. function Addition_Callback(hObject, eventdata, handles) % hObject handle to Addition (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) OLDstring=get(handles.text1,'string'); NEWstring=('+'); textstring=strcat(OLDstring,NEWstring); set(handles.text1,'string',textstring);
% --- Executes on button press in Sine. function Sine_Callback(hObject, eventdata, handles) % hObject handle to Sine (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) textstring=get(handles.text1,'string'); textstring=strcat(textstring,'sin(pi/180*'); set(handles.text1,'string',textstring);
% --- Executes on button press in Equal. function Equal_Callback(hObject, eventdata, handles) % hObject handle to Equal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) textstring=get(handles.text1,'string'); textstring=eval(textstring); set(handles.text1,'string',textstring);
0 个评论
回答(1 个)
Walter Roberson
2018-5-1
You appear to be using guide.
You do not have a uicontrol with tag text1
Perhaps you had a control with that name but renamed it but forgot to change the reference in the code.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!