blob: 4d13c6248f2eb3890713eeb5ca9db1e54898ae52 (
plain)
1
2
3
4
5
|
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
|