Matlab GUI popupmenu problem
5 次查看(过去 30 天)
显示 更早的评论
Hello;
I used popupmenu in Matlab GUI why it refuse to write in the output box
0 个评论
回答(1 个)
Geoff Hayes
2022-3-15
@Huda M - the red text in your screen shot is the error message so it is telling you what is going wrong. It would be helpful to copy and paste the full error message to this question so that anyone can get an idea of what is happening. Looking at your code though (again, copying and pasting the code is more helpful than a screen shot)
set(handles.output, 'string', 1)
it seems that you are setting the output text field string property with an integer. Try doiing
set(handles.output, 'string', '1')
instead where you set the string property with a string. Please do that for each of the four conditions.
5 个评论
Geoff Hayes
2022-3-16
@Huda M - I think the problem is the name of your text (edit) control. It can't be named output as that conflicts with a default line of code in the OpeningFcn of your GUI. If I create a GUIDE GUI, I see the following
% --- Executes just before untitled2 is made visible.
function untitled2_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 untitled2 (see VARARGIN)
% Choose default command line output for untitled2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
Note the line
handles.output = hObject;
which overrides your text control with the handle to the figure. And so the error message Unrecognized property string for class Figure makes sense. Just rename your text control to something else and your GUI should work fine.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!