popupmenu in GUI gives error when calling a function AND set(handles.text,'string','dense') - but not when using only one of the two
조회 수: 1 (최근 30일)
이전 댓글 표시
I have created a GUI with a popupmenu. Only two choices. Choice 1 works well, Choice 2 only works if I take out either row 2 or row 4 in code below. If I leave in all four lines then I get an error - see error below code. Line 3 does not make a difference (if I take it out I just change dense to 'dense'). I am rather stuck as I think this code worked a few days ago.
function popupmenu1_Callback(hObject, eventdata, handles)
contents = get(hObject,'Value');
I_bw_tissue=handles.I_bw_tissue;
I_lessSkin=handles.I_lessSkin;
I_bw_sml=handles.I_bw_sml;
if contents == 1
set(handles.text26,'string', 'N/A');
elseif contents == 2
cd 'C:\Users\Documents\Code_Density'; [1]
[total_per, str_dense] = ROI_density(I_bw_tissue,I_lessSkin, I_bw_sml); [2]
dense = 'Do not know' %strcat([str_dense,'; ', num2str(total_per),'%']) [3]
set(handles.text26,'string', dense); [4]
end
guidata(hObject,handles)
And the error when having all 4 lines in:
Error using matlab.ui.control.UIControl/set
Invalid or deleted object.
Error in OpenFolder>popupmenu1_Callback (line 135)
set(handles.text26,'string', dense);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in OpenFolder (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)OpenFolder('popupmenu1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating DestroyedObject Callback
As mentioned, when running this with lines 1,2 and 3, it works, when running with lines 1,3,4 - it works and displays, but not when I run lines 1,2,3 and 4
댓글 수: 0
채택된 답변
Walter Roberson
2017년 6월 23일
I suspect that your ROI_density routine has a "clear all" or "close all" statement.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!