These lines make sigma and beta tables with one variable each
sigma = data(:,5); beta = data(:,6);
which produces the error when you try to index them with one subscript, as in sigma(m+1), later on.
Instead, make sigma and beta column vectors (presumably of a numeric type):
sigma = data.(5); beta = data.(6);
https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html