Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Problem with GUI when trying to run it

4 visualizaciones (últimos 30 días)
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan el 9 de Mzo. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
function Speed_Callback(hObject, eventdata, handles)
user_entry=str2double(get(hObject,'string'));
if isnan(user_entry)
errordlg('You must enter a numeric value','Bad Input','modal')
uicontrol(hObject)
return
end
% Proceed with callback
% hObject handle to Speed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Speed as text
% str2double(get(hObject,'String')) returns contents of Speed as a double
% --- Executes during object creation, after setting all properties.
function Speed_CreateFcn(hObject, eventdata, handles)
% hObject handle to Speed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Calculate.
function Calculate_Callback(hObject, eventdata, handles)
string=get(Speed_Callbackhandle,'user_entry');
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
user_entry=str2double(get(handles.Speed_Callback,'string')); % for example
user_entry =h;
Newfunction (h)
I am not understanding why I am still getting error messages
??? Undefined function or variable 'Speed_Callbackhandle'.
Error in ==> Stallfunction>Calculate_Callback at 105 string=get(Speed_Callbackhandle,'user_entry');
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> Stallfunction at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)Stallfunction('Calculate_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Mzo. de 2013
  3 comentarios
Walter Roberson
Walter Roberson el 9 de Mzo. de 2013
At the end of your first routine, add
handles.user_entry = user_entry;
guidata(hObject, handles);
Then replace your last callback code with
h = handles.user_entry;
NewFunction(h);
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan el 10 de Mzo. de 2013
I have done as you said but I keep getting errors that user_entry is not defined
% --- Executes just before Stallfunction is made visible.
function Stallfunction_OpeningFcn(hObject, ~, 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 Stallfunction (see VARARGIN)
% Choose default command line output for Stallfunction
handles.user_entry = user_entry;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Stallfunction wait for user response (see UIRESUME)
% uiwait(handles.figure1);
I have inserted the code at the end of the first routine

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by