Automatically select a checkbox

8 views (last 30 days)
I am new in the GUI Matlab world. What I would like to is to create a GUI that will review a plot and help select certain adjustments. I have created a small Matlab program that will review the plots and create a vector of the output. What I would like help on, is for the GUI to look at one point in the vector and preselect a checkbox for the person. The person will be able to review what has been selected and remove the checkmark if they decide it is not necessary.
% --- Executes just before StackedGUI is made visible.
function StackedGUI_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 command line arguments to StackedGUI (see VARARGIN)
% Choose default command line output for StackedGUI
handles.output = hObject;
%Input of file
Sen = dlmread('file.txt',',','A3..G803');
nom = dlmread('textn.txt',',','A3..G803');
Senestive_help;
%Plotting to Axis
axes(handles.axes1)
plot(nom(:,1),nom(:,2),Sen(:,1),Sen(:,2));
xlabel('Time (sec)');
ylabel('X (ft)');
title('X');
grid on
axes(handles.axes2)
plot(nom(:,1),nom(:,3),Sen(:,1),Sen(:,3));
xlabel('Time (sec)');
ylabel('Y (ft)');
title('Y');
grid on
axes(handles.axes3)
plot(nom(:,1),nom(:,4),Sen(:,1),Sen(:,4));
xlabel('Time (sec)');
ylabel('Z (ft)');
title('Z');
grid on
axes(handles.axes4)
plot(nom(:,1),nom(:,5),Sen(:,1),Sen(:,5));
xlabel('Time (sec)');
ylabel('Psi (deg)');
title('Psi');
grid on
axes(handles.axes5)
plot(nom(:,1),nom(:,6),Sen(:,1),Sen(:,6));
xlabel('Time (sec)');
ylabel('Theta (deg)');
title('Theta');
grid on
axes(handles.axes6)
plot(nom(:,1),nom(:,7),Sen(:,1),Sen(:,7));
xlabel('Time (sec)');
ylabel('Phi (deg)');
title('Phi');
grid on
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes StackedGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = StackedGUI_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
varargout{1} = handles.output;
% --- Executes on button press in checkbox1.
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
if a1(1)>= 1;
(get(hObject,'Value') == get(hObject,'Max'));
end
Senestive_help creates a vector (which is mentioned above) a1. This vector will help determine whether or not the checkbox should be selected or not. Where in the checkbox1 will bring up one point in the vector to see if the value is one or greater and check the box.
Example vector a1=[1 0 3 2 0]
For this example, checkbox1 should be automatically selected since a1(1)>=1.
Any help would be appreciated.

Accepted Answer

Sean de Wolski
Sean de Wolski on 6 Nov 2014
Edited: Sean de Wolski on 6 Nov 2014
Set the value of it:
checkbox = uicontrol('style','checkbox');
set(checkbox,'Value',true)
Since you're using GUIDE, you'll need to apply this to the checkboxes in handles

More Answers (1)

Bruce Headley
Bruce Headley on 13 Nov 2014
Sorry for the delay response. This is what I have placed underneath the place for the checkbox1 position.
a1=[1 0 0 1];
if a1(1)==1;
checkbox=uicontrol('Style','checkbox1');
set(checkbox,'Vaule',true);
end
I am assuming this is incorrect since the code is not automatically input the check mark in the appropriate box.
  2 Comments
Sean de Wolski
Sean de Wolski on 14 Nov 2014
It'll be something like
set(handles.checkbox1,'Value',true)
But you have a typo above and you're adding a new uicontrol which is not what I suspect you want to do.
Bruce Headley
Bruce Headley on 14 Nov 2014
Perfect, I appreciate the help.

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!