MATLAB: Questions on errors in GUIDE

tableui

EDITED Hi there can someone help me to decipher the problem with my program, I have been receiving these error messages when i input data into my uitable and clicking the push button to run my code 'compare'. My code is as follows and the error message is attached behind it.
>> function Sample2_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 Sample2 (see VARARGIN)
% Choose default command line output for Sample2
handles.output = hObject;
storedvals = zeros(1,4);
% Update handles structure
guidata(hObject, handles);
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
storedvals = handles.storedvals;
x = 0;
tableData = get(handles.uitable1, 'data');
compare(storedvals(1),storedvals(3));
if flag == 1
x = 'P1 Complies with A, B and C';
end
if flag == 2
x = 'P1 Complies with C and B';
end
if flag == 3
x = 'P1 Complies with A and C';
end
if flag == 4
x = 'P1 Complies with A';
end
if flag == 5
x = 'P1 Complies with B and C';
end
if flag == 6
x = 'P1 Complies with C';
end
if flag == 7
x = 'P1 Complies with C';
end
if flag == 8
x = 'Complies with None';
end
if flag == 9
x = 'P2 Complies with A, B and C';
end
if flag == 10
x = 'P2 Complies with A and B';
end
if flag == 11
x = 'P2 Complies A and C';
end
if flag == 12
x = 'P2 Complies A';
end
if flag == 13
x = 'P2 Complies with B and C';
end
if flag == 14
x = 'P2 Complies with C';
end
if flag == 15
x = 'P2 Complies with C';
end
if flag == 16
x = 'Complies with None';
end
set(handles.uitable1, 'Data', x)
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
data = get(hObject, 'data');
indices = eventdata.Indices;
r = indices(:,1);
c = indices(:,2);
linear_index = sub2ind(size(data),r,c);
storedvals(linear_index) = data(linear_index);
handles.storedvals = storedvals;
guidata(hObject, handles);
>> Sample2
Undefined operator '==' for input arguments of type 'cell'.
Error in compare (line 3)
if Proc==1
Error in Sample2>pushbutton1_Callback (line 112)
compare(storedvals(1),storedvals(3));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Sample2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Sample2('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Best Answer

handles.storedvals is a cell array of the data in the uitable, therefore you need cell array indexing to access its contents:
compare(storedvals{1},storedvals{3});