is it possible to fit the parameters of a non linear model with more than 2 independent variable (let's say 3 or 4 for example) to data???
here attached is my code, where the coefficients are a b c d and the independent variables are x,q,w
function [beta]=fitgen(Xtest,Ytest,Wtest,Ztest,p,p_low,p_up)
mdl=@(a,b,c,d,w,q,x) zfit(a,b,c,d,w,q,x);
algo1='Trust-Region';
fit_opt = fitoptions('Method','NonlinearLeastSquares',… 'Lower',p_low,'Upper',p_up,… 'Robust','on',… 'Normalize','off',… 'Algorithm',algo1); fit_typ = fittype(mdl,'option',fit_opt);
[Yfitt,gof,output]=fit([Xtest,Ytest,Wtest],Ztest,fit_typ,'Start',p)
%%where the function zfit is (I used a linear model just for sake of simplicity, but the final purpose is to fit a non linear model):
function [z]=zfit(a,b,c,d,w,q,x)
[x,q,w]=meshgrid(x,q,w);
z=a*x+b*q+c*w+d;
end
thank you very much in advance
Best Answer