function polynom = regress(x, y, degree) pot = @(x) x.^[degree:-1:0]; M = reshape(cell2mat(arrayfun(pot, x(:)', 'UniformOutput', false)), degree+1, [])'; polynom = M \ y(:); endfunction