MATLAB: How to get around the Phrase “Undefined operator ‘-‘ for input arguments of type ‘table”.

errortable

for i=0;
for i = params1
icount = icount + 1;
jcount= 0;
for j= params2
jcount= jcount +1;
kcount=0;
for k = params3
kcount = kcount + 1;
SimulatedY = MultipleRegression([i j k],Data);
SSD = Data(:,3)-SimulatedY.^2 **** line 17
I get this: Undefined operator '-' for input arguments of type 'table'. Error in MultipleRegressionIterativeSearch (line 17).
I havent shown all of my code but i was wondering how to get around this? Ive tried turning the column im interested in into an array and then indexing the column of the array but that didnt work either.

Best Answer

Check the class of Data and SimulatedY by running
class(SimulatedY)
class(Data)
If anyone of them has table class, first use table2array to convert it into a matrix and then do subtraction.
As a side note, it appears that the last statement is mathematically wrong, what you really want to do can square the errors like this
SSD = (Data(:,3)-SimulatedY).^2