MATLAB: How to multiple elements of a table

linear regressiontable

I am trying to create a simple linear regression model. a.csv contains 8 columns. Var1 month dow Hour is_holiday T load Date. I get an error at X = ones… it says undefined unction times for input arguments of type table.
T = readtable('a.csv')
x1 = T(:, 6);
x2 = T(:,3);
y = T(:,7);
X = [ones(size(x1)) x1 x2 x1.*x2];
b = regress(y,X)

Best Answer

To get data from the column of a table you must refer to the column by name, e.g.
T =
3×2 table
a b
_ _
1 4
2 5
3
>> T.b
ans =
4
5
6
Related Question