0
在下面的代码中,当用户按下一个按钮时,将从命令窗口中读取并显示弹出式菜单中的选定值。选项是“轻微”,“中等”和“严重”。当我选择前两个选项时,我得到selectedSeverity = mild (or moderate)
。但是,当我选择严重时,我得到这个selectedSeverity = [1x7 char]
。我不知道我在做什么错,或者我错过了什么。任何帮助表示赞赏。弹出式菜单上的最后一项值不显示在MATLAB GUI中
% --- Executes on button press in addNotesButton.
function addNotesButton_Callback(hObject, eventdata, handles)
% hObject handle to addNotesButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
contents = get(handles.artSevSel, 'String');
selectedSeverity = contents(get(handles.artSevSel, 'Value'))
return
您可能需要使用{花括号}来访问单元格数组中的字符串。即'contents {get(handles.artSevSel,'Value')}'。是吗? –
@ Benoit_11现在好了,现在它在物理重新输入行后出现某种原因... welp thanks! – DeeWBee
哈哈是啊这些事情发生的时候:)很高兴它的作品! –