Borrar filtros
Borrar filtros

how to write callback for check box

30 visualizaciones (últimos 30 días)
rafi abdul
rafi abdul el 4 de Feb. de 2013
hi how to write code to remove plot by unchecking check box.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (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 checkbox1
data=get(handles.uitable1,'data');
plot(data(:,1),data(:,2));
as per above callback i am able to plot when checkbox is checked, please guide me how to write code for unchecking checkbox so that plot gets deleted

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Feb. de 2013
if get(hObject, 'Value')
handles.plot = plot(data(:,1),data(:,2));
else
delete(handles.plot);
handles.plot = [];
end
guidata(hObject, handles);

Más respuestas (1)

rafi abdul
rafi abdul el 4 de Feb. de 2013
Editada: Azzi Abdelmalek el 4 de Feb. de 2013
thanks for reply walter.it was very helpful.actually i have 3 plots in my code .when 3 plots are displayed in figure i want to select one plot and zoom in x and y direction.can you guide me how to proceed further .
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (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 checkbox1
data=get(handles.uitable1,'data');
if get(hObject, 'Value')
handles.plot1 = plot(data(:,1),data(:,2));
else delete(handles.plot1);
handles.plot1 = [];
endguidata(hObject, handles);
% --- 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
data=get(handles.uitable1,'data');
if get(hObject, 'Value')
handles.plot2 = plot(data(:,1),data(:,3));
else delete(handles.plot2);
handles.plot2 = [];
endguidata(hObject, handles);
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (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 checkbox3
data=get(handles.uitable1,'data');
if get(hObject, 'Value')
handles.plot3 = plot(data(:,1),data(:,4));
else
delete(handles.plot3);
handles.plot3 = [];endguidata(hObject, handles);

Categorías

Más información sobre Programming Utilities en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by