I'm making a GUI that reads out data from a measurement board via a serial interface. It consists of 8 channels and I want to be able to enable and disable the channels in the figure plot, but the state of my variable handles.channelsEnable isn't saved.
When opening the GUI: handles.channelEnable = [0;0;1;1;0;0;0;0]; While running the GUI I want to modify a handles.channelEnable. Inside the callback function of a checkbox it is changed, but not outside the function. I'm using guidata(hObject,handles) to save the changes made. Why aren't the changes made to handles.channelEnable saved?
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox2
handles.channelEnable(2) = get(hObject,'Value');
guidata(hObject, handles);
end