How to clear variable from GUI?
25 views (last 30 days)
I am plotting from a structure called handles.data. I have a push button to clear all graphs and this structure to plot other things, but the clear command doesn't seem to be working. When I try to replot using the same code as before, I get an error saying "Subscripted assignment between dissimilar structures." When I check handles.data, I have a struct with no fields. How would I just remove the variable completely?
Adam on 16 Jun 2017
Edited: Adam on 16 Jun 2017
handles.data = ;
will reset the field to empty (which is what I usually do because I use an isempty(...) test when using the data)
handles = rmfield( handles, 'data' );
would remove the field.
clear is used for clearing variables, you can't clear a field of a structure with it.
would be valid syntax, but do not do this in a GUI as it will remove the whole structure and make your GUI unusable.