StartPoint function for General model Fourier1
조회 수: 11 (최근 30일)
이전 댓글 표시
Here is the model(a0,a1,b1,w,x) = a0 + a1*cos(x*w) + b1*sin(x*w). I try to use curve fitting function. I want to find out the function [start, anError, aWarning] = iCheckStartPoint( start, model, probparams, xdata, ydata ), which is built in the funtion fit.m.(Matlab 2015a) How to compute the startpoint for the model(fourier1)? What's the meaning for the following code?
function [start, anError, aWarning] = iCheckStartPoint( start, model, probparams, xdata, ydata ) % iCheckStartPoint Ensure that the start point is valid. Throw errors or % warnings if it is not valid. anError = ''; aWarning = ''; numcoeff = numcoeffs( model );
% If the start point is empty, then use the model to estimate a start point if isempty( start ) startPointFcn = startpt( model );
% If there is no function to estimate the start point, then we need to use a
% random start point.
if isempty( startPointFcn )
aWarning = message( 'curvefit:fit:noStartPoint' );
start = rand( numcoeff, 1 );
else
% Get constants for library functions
someConstants = constants( model );
try
start = startPointFcn( probparams{:}, xdata, ydata, someConstants{:} );
catch es
anError = es;
return
end
end
end
% Start points must be finite and real. if ~all(isfinite(start)) ~isreal(start) aWarning = message( 'curvefit:fit:invalidStartPoint' ); start = rand(size(start)); end
% There has to be exactly one start point per coefficient if numel( start ) < numcoeff anError = message( 'curvefit:fit:tooFewStartPoints', int2str( numcoeff ) ); return end if numel( start ) > numcoeff anError = message( 'curvefit:fit:tooManyStartPoints', int2str( numcoeff ) ); return end end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!