suppose that I have gui code which generates a plot by ticking a checkbox. how can I delete the drawn graph by removing the tick. thanks in advance.
So this is my code, step1 and sound are two checkboxes that generate different figures according to the radio buttons. can you please help me to do the same that you did with my m.file? I really appreciate
function varargout = RotPlot(varargin)
%ROTPLOT M-file for RotPlot.fig
% ROTPLOT, by itself, creates a new ROTPLOT or raises the existing
% singleton*.
%
% H = ROTPLOT returns the handle to a new ROTPLOT or the handle to
% the existing singleton*.
%
% ROTPLOT('Property','Value',...) creates a new ROTPLOT using the
% given property value pairs. Unrecognized properties are passed via
% varargin to RotPlot_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% ROTPLOT('CALLBACK') and ROTPLOT('CALLBACK',hObject,...) call the
% local function named CALLBACK in ROTPLOT.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help RotPlot
% Last Modified by GUIDE v2.5 07-Mar-2016 13:59:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @RotPlot_OpeningFcn, ...
'gui_OutputFcn', @RotPlot_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before RotPlot is made visible.
function RotPlot_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
movegui('center')
set(hObject , 'Name' , varargin{2})
setappdata(0 , 'Axial1' , varargin{3})
setappdata(0 , 'Axial2' , varargin{4})
setappdata(0 , 'Tor1' , varargin{5})
setappdata(0 , 'Tor2' , varargin{6})
setappdata(0 , 'sheary1' , varargin{7})
setappdata(0 , 'sheary2' , varargin{8})
setappdata(0 , 'shearz1' , varargin{9})
setappdata(0 , 'shearz2' , varargin{10})
setappdata(0 , 'momenty1' , varargin{11})
setappdata(0 , 'momenty2' , varargin{12})
setappdata(0 , 'momentz1' , varargin{13})
setappdata(0 , 'momentz2' , varargin{14})
% Choose default command line output for RotPlot
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes RotPlot wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = RotPlot_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
% --- Executes during object creation, after setting all properties.
function SecForce_CreateFcn(hObject, eventdata, handles)
% hObject handle to SecForce (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --------------------------------------------------------------------
function SecForce_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to SecForce (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes when selected object is changed in SecForce.
function SecForce_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in SecForce
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in closebutton.
function closebutton_Callback(hObject, eventdata, handles)
% hObject handle to closebutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(handles.figure1)
% --- Executes on button press in sound.
function sound_Callback(hObject, eventdata, handles)
% hObject handle to sound (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 sound
Axial1 = getappdata(0 , 'Axial1' );
Tor1 = getappdata(0 , 'Tor1');
sheary1 = getappdata(0 , 'sheary1');
shearz1 = getappdata(0 , 'shearz1');
momenty1 = getappdata(0 , 'momenty1');
momentz1 = getappdata(0 , 'momentz1');
if (get(hObject , 'Value') == get(hObject , 'Max'))
switch get(get(handles.SecForce , 'selectedObject') ,'Tag')
case 'axial'
p1 = plot(Axial1 , 'red');
xlabel('Sections')
ylabel('Axial Force (Kg)')
title('Axial Force')
hold on
case 'tor'
p2 = plot(Tor1 , 'red');
xlabel('Sections')
ylabel('Torsion (Kg.cm)')
title('Torsion')
hold on
case 'sheary'
p3 = plot(sheary1 , 'red');
xlabel('Sections')
ylabel('Shear (Kg)')
title('Shear Force in xy plane')
hold on
case 'shearz'
p4 = plot(shearz1 , 'red');
xlabel('Sections')
ylabel('Shear (Kg)')
title('Shear Force in xz plane')
hold on
case 'momenty'
p5 = plot(momenty1 , 'red');
xlabel('Sections')
ylabel('Moment (Kg.cm)')
title('Moment about y axis')
hold on
case 'momentz'
p6 = plot(momentz1 , 'red');
xlabel('Sections')
ylabel('Moment (Kg.cm)')
title('Moment about z axis')
hold on
end
end
visibility = {'off', 'on'};
set(p1, 'Visible', visibility{get(hObject, 'value') + 1})
% --- Executes on button press in step1.
function step1_Callback(hObject, eventdata, handles)
% hObject handle to step1 (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 step1
Axial2 = getappdata(0 , 'Axial2');
Tor2 = getappdata(0 , 'Tor2');
sheary2 = getappdata(0 , 'sheary2');
shearz2 = getappdata(0 , 'shearz2');
momenty2 = getappdata(0 , 'momenty2');
momentz2 = getappdata(0 , 'momentz2');
if (get(hObject , 'Value') == get(hObject , 'Max'))
switch get(get(handles.SecForce , 'selectedObject') ,'Tag')
case 'axial'
p7 = plot(Axial2 , 'blue');
xlabel('Sections')
ylabel('Axial Force (Kg)')
title('Axial Force')
hold on
case 'tor'
p8 = plot(Tor2 , 'blue');
xlabel('Sections')
ylabel('Torsion (Kg.cm)')
title('Torsion')
hold on
case 'sheary'
p9 = plot(sheary2 , 'blue');
xlabel('Sections')
ylabel('Shear (Kg)')
title('Shear Force in xy plane')
hold on
case 'shearz'
p10 = plot(shearz2 , 'blue');
xlabel('Sections')
ylabel('Shear (Kg)')
title('Shear Force in xz plane')
hold on
case 'momenty'
p11 = plot(momenty2 , 'blue');
xlabel('Sections')
ylabel('Moment (Kg.cm)')
title('Moment about y axis')
hold on
case 'momentz'
p12 = plot(momentz2 , 'blue');
xlabel('Sections')
ylabel('Moment (Kg.cm)')
title('Moment about z axis')
hold on
end
end
% --- Executes on button press in axial.
function axial_Callback(hObject, eventdata, handles)
% hObject handle to axial (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 axial
cla
% --- Executes on button press in tor.
function tor_Callback(hObject, eventdata, handles)
% hObject handle to tor (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 tor
cla
% --- Executes on button press in sheary.
function sheary_Callback(hObject, eventdata, handles)
% hObject handle to sheary (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 sheary
cla
% --- Executes on button press in shearz.
function shearz_Callback(hObject, eventdata, handles)
% hObject handle to shearz (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 shearz
cla
% --- Executes on button press in momenty.
function momenty_Callback(hObject, eventdata, handles)
% hObject handle to momenty (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 momenty
cla
% --- Executes on button press in momentz.
function momentz_Callback(hObject, eventdata, handles)
% hObject handle to momentz (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 momentz
cla
% --- Executes on key press with focus on sound and none of its controls.
function sound_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to sound (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
clf
, I guessclf(figurehandle)
?