MATLAB: Want to fit data,in which I have 5 independent variables and 1 dependent variable.

multivariable linear data fitting

I want a model in the form B = A1 * X1 + A2 * X2 + A3 * X3 + A4 * X4 + A5 * X5
A1,A2..A5 are independent variables and are column vectors. B is the dependent variable and is also a column vector.
I went through the forums and found similar posts where people have asked to use some function, fun= @(b,X) b(1).*X(:,1)+b(2).*X(:,2)+b(3).*X(:,3)+b(4).*X(:,4)+ b(5).*X(:,5);
and then 'nlinfit' command at the end,but I am getting some weird plots.
Would appreciate any kind of help. Thanks

Best Answer

I suspect the weird plots are because you cannot plot a 6-dimensional function (in this universe). If you want to find out how good the fit is, use the regress function since you have a linear model. It will provide you with all the statistics you need just by asking it to output them.