フィルターのクリア

how to write callback for check box

13 ビュー (過去 30 日間)
rafi abdul
rafi abdul 2013 年 2 月 4 日
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

採用された回答

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

その他の回答 (1 件)

rafi abdul
rafi abdul 2013 年 2 月 4 日
編集済み: Azzi Abdelmalek 2013 年 2 月 4 日
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);
  1 件のコメント
Jan
Jan 2013 年 2 月 4 日
Please learn how to format code.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by