Error while evaluating UIControl Callback.

Hi there, my push button code does not work, it is almost identical to the code of a different pushbutton which is just to open a different GUI.
% --- 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)
run game.m
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
run howtoplay.m
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)attempt2('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Pushbutton2 works, pushbutton1 does not.

4 个评论

Is this the complete error message? We see, where the problem occurred, but usually the message contains a hint also, what the error is. Maybe there is a typo inside game.m?
Prefer to use functions instead of scripts. Calling a script through run ... is less smart and prone to bugs.
That is the complete error message to the best of my knowledge, however, i will attach the relevent files.
How else could i get the pushbutton to open the new GUI
I have attactched all three of my m files
Accepting an answer means, that your problem is solved. Is this correct?
Yes it is, thank you for your help

请先登录,再进行评论。

 采纳的回答

Stephen23
Stephen23 2018-12-28
编辑:Stephen23 2018-12-28

2 个评论

Thank you for your help,
Why does pushbutton 2 run correctly?
I would avoide using GUIDE if it wasn't just one university project i have to do, as my course is not programming based, and this is my only programming module, i want to do this project as easily as i can, and the lecturer recommended using GUIDE
"Why does pushbutton 2 run correctly?"
Because the code inside does not throw an error. Presumably howtoplay.m is a script on the MATLAB search path.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by