Reputation: 11
So I have been having problems with my GUI where whenever I select an item from the list box, it automatically just outputs the file. Whereas I want it to just wait for the push button click. I am using GUIDE in matlab.
index_selected = get(hObject,'Value');
Materials = {ABS,AL,CB,HIPS,KAOWOOL,Kydex,PEI,PET,PMMA,POM};
RMAT = (Materials(index_selected));
dlmwrite('Results.cmp',RMAT,'');
Upvotes: 0
Views: 229
Reputation: 2334
The listbox
callback is always executed when changing the element in the listbox
. Move your code from the callback to the callback of the button
.
index_selected = get(handles.handleToListbox,'Value');
Materials = {ABS,AL,CB,HIPS,KAOWOOL,Kydex,PEI,PET,PMMA,POM};
RMAT = (Materials(index_selected));
dlmwrite('Results.cmp',RMAT,'');
Then, only when pressing the button
, the file will be created. Replace handles.handleToListbox
with the actual correct handle name (see tag in the object inspector).
Upvotes: 2