StartPoint function for General model Fourier1

3 次查看(过去 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 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!