MATLAB - least square curve fit for multiple independent variables -
i have following function:
i'd coefficients least squares method
matlab function lsqcurvefit.
the problem is, don't know, if it's possible use function when function t
has multiple independent variables , not one. so, according link should have multiple xdata
vectors - this:
lsqcurvefit(f, [1 1 1], nprocs, ndoms, ndof, measuredvals)
do know how it?
my attempt
i've tried define objective function this
f = @(c, x) c(1)*x(2).^(c(2)*x(1).^c(3)) + (c(4) + c(5)*x(1))/x(3);
and use lsqcurvefit
this
lsqcurvefit(f, [1 1 1], [ndoms ndof nprocs], measuredvals),
but there's problem, measuredvals
vector of size 56x1, "xdata" matrix of size 56x3, i'm getting error:
index exceeds matrix dimensions. error in factorizatonkglobregr>@(c,x)c(1)*x(2).^(c(2)*x(1).^c(3))+(c(4)+c(5)*x(1))/x(3) error in lsqcurvefit (line 202) initvals.f = feval(funfcn_x_xdata{3},xcurrent,xdata,varargin{:}); caused by: failure in initial objective function evaluation. lsqcurvefit cannot continue.
but how supposed this, when $t: \mathbb{r}^3 \rightarrow \mathbb{r}$?
second attempt
i've changed objective function to
f = @(c, x) c(1)*x(:,2).^(c(2)*x(:,1).^c(3)) + (c(4) + c(5)*x(:,1))/x(:,3);,
but error remains.
my data
measuredvals = [ 0.1647815 0.06300775 0.05769325 0.04803725 0.04290825 0.0405065 0.03807525 0.03487725 0.284112 0.13495675 0.12740075 0.11109725 0.105036 0.11022575 0.100587 0.09803775 0.48695475 0.30563525 0.30084925 0.283312 0.2745085 0.271998 0.27472625 0.27103925 0.89953925 0.68234025 0.6783635 0.65540225 0.64421475 0.64214725 0.63949875 0.623119 1.588605 1.37335275 1.36082075 1.35097375 1.34813125 1.34932025 1.3519095 1.34521625 2.820884 2.63251325 2.640659 2.6338805 2.636361 2.62748 2.6233345 2.63821 4.81472975 4.65116425 4.664892 4.64225625 4.6734825 4.63981675 4.635483 4.6280245]; n = 56; ndoms = []; i=1:n ndoms = [ndoms; 288]; end tmp = [ 375 1029 2187 3993 6591 10125 14739]; ndof = []; i=1:7 j=1:8 ndof = [ ndof tmp(i)]; end end nprocs = []; i=1:7 nprocs = [nprocs; [1 2 3 4 6 8 12 24]']; end
when tested objective function simulated c , x input, returned nxn matrix size of data set. shouldn't case. should single value each data set expect nx1 matrix. try updating function this
f = @(c, x) c(1).*x(:,2).^(c(2).*x(:,1).^c(3)) + (c(4) + c(5)*x(:,1))./x(:,3)
i added period divisor.
Comments
Post a Comment