Info
此问题已关闭。 请重新打开它进行编辑或回答。
Problem with GUI when trying to run it
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Walter Roberson
2013-3-9
3 个评论
Walter Roberson
2013-3-9
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);
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!