From: Corey Kelly on 9 Jul 2010 17:02 My GUI has multiple imEllipse objects, the handles for which are all stored in handles.rois. I keep track of how many ROIs have been created by incrementing a variable handles.nrois every time one is constructed. My GUI has a reset button which is meant to remove all of these ROIs and remove their handles. I currently have this set up as follows: function resetroi_button_Callback(hObject, eventdata, handles) for i = 1:handles.nrois delete(handles.rois(i)); end handles.nrois = 0; clear handles.rois; guidata(hObject, handles); It doesn't seem like handles.rois is being emptied. The ROIs are being deleted, and handles.nrois is being properly reset, but the rois variable doesn't seem affected. I can overwrite the array values with new handles, but if I don't overwrite them all, I get errors regarding removed objects.
From: Walter Roberson on 9 Jul 2010 17:00 Corey Kelly wrote: > My GUI has multiple imEllipse objects, the handles for which are all > stored in handles.rois. I keep track of how many ROIs have been created > by incrementing a variable handles.nrois every time one is constructed. > My GUI has a reset button which is meant to remove all of these ROIs and > remove their handles. I currently have this set up as follows: > > function resetroi_button_Callback(hObject, eventdata, handles) > for i = 1:handles.nrois > delete(handles.rois(i)); > end > handles.nrois = 0; > clear handles.rois; > guidata(hObject, handles); > > It doesn't seem like handles.rois is being emptied. The ROIs are being > deleted, and handles.nrois is being properly reset, but the rois > variable doesn't seem affected. I can overwrite the array values with > new handles, but if I don't overwrite them all, I get errors regarding > removed objects. You do not 'clear' a field of a structure: you rmfield() it. handles = rmfield(handles, 'rois');
From: Corey Kelly on 9 Jul 2010 17:13 Walter Roberson <roberson(a)hushmail.com> wrote in message <i182rq$5gb$2(a)canopus.cc.umanitoba.ca>... > Corey Kelly wrote: > > My GUI has multiple imEllipse objects, the handles for which are all > > stored in handles.rois. I keep track of how many ROIs have been created > > by incrementing a variable handles.nrois every time one is constructed. > > My GUI has a reset button which is meant to remove all of these ROIs and > > remove their handles. I currently have this set up as follows: > > > > function resetroi_button_Callback(hObject, eventdata, handles) > > for i = 1:handles.nrois > > delete(handles.rois(i)); > > end > > handles.nrois = 0; > > clear handles.rois; > > guidata(hObject, handles); > > > > It doesn't seem like handles.rois is being emptied. The ROIs are being > > deleted, and handles.nrois is being properly reset, but the rois > > variable doesn't seem affected. I can overwrite the array values with > > new handles, but if I don't overwrite them all, I get errors regarding > > removed objects. > > You do not 'clear' a field of a structure: you rmfield() it. > > handles = rmfield(handles, 'rois'); Excellent! Thanks Walter.
|
Pages: 1 Prev: remove duplicate rows in sparse matrix Next: Converting m file to pcode error... |