Multiple Variable Non Linear Regression OR Curve Fitting Matlab -
i have set of noisy data , want fit custom equation though in matlab. next take values of coefficients , utilize them in algorithm. stuck , cant figure out why. use non linear equation a+b*log10(x1-dcos(alpha-x2)) x1,x2 , response value known. first problem coefficients of ,b, , alpha must bounded. alpha here being in degrees can vary 0 360 example.i dont know how achieve using curve fitting toolbox.
i have tried other options non linear regression techniques in matlab( fitnlm,lsqcurvefit etc) proved disappointing cant have bounds on these variables. in spite of fit being quite good, coefficients way bad.
so, question 1 : how fit multiple variables using curve fitting ? question 2 : if thats not possible other techiniques can use except non linear regression .
many thnaks in advance ! have great day !
well if problem have set of data, variables x1 , x2 , thre result y, , want model equation:
y = + b * log10(x1 - cosd(alpha - x2)) % suppose dcos = cosd, not known functions
first create data values:
function y = getting_data(x1,x2) = 3; b = 5; alpha = 120; y = + b * log10(x1 - cosd(alpha - x2));
now let's generate de datasets
>> % generate data sets >> x1 = 9 .* rand(1000,1) + 1; % random values [1,10] >> x2 = 360 .* rand(1000,1); % random values [0,360] >> y = getting_data(x1,x2); % values function
create function use curve fitting model
function myfit = fitting_data(x1,x2,y) myfittype = fittype('a + b * log10(x1 - cosd(alpha - x2))',... 'dependent',{'y'},'independent',{'x1','x2'},... 'coefficients',{'a','b','alpha'}) myfit = fit([x1 x2],y,myfittype)
be carefull input vector should nx1 fit function
and coefficients:
>> fitting_data(x1,x2,y) myfittype = general model: myfittype(a,b,alpha,x1,x2) = + b * log10(x1 - cosd(alpha - x2)) warning: start point not provided, choosing random start point. > in curvefit.attention.warning/throw (line 30) in fit>ifit (line 299) in fit (line 108) in fitting_data (line 7) general model: myfit(x1,x2) = + b * log10(x1 - cosd(alpha - x2)) coefficients (with 95% confidence bounds): = 3 (3, 3) b = 5 (5, 5) alpha = 120 (120, 120) general model: ans(x1,x2) = + b * log10(x1 - cosd(alpha - x2)) coefficients (with 95% confidence bounds): = 3 (3, 3) b = 5 (5, 5) alpha = 120 (120, 120)
wich represent values guess
also usefull separe de con(a - b) this:
and remember that
Comments
Post a Comment