how to select proper parameters for "opt.StartPoint" ?

12 views (last 30 days)
I want to fit some data as below code witch generate from curve fitting tool:
[xData, yData] = prepareCurveData( x, y );
ft = fittype( 'c*x^(a*sin(x*b)^2)', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.452987881098739 0.698037618662922 0.104515161828401];
[fitresult, gof] = fit( xData, yData, ft, opts );
How can I know the best start points?

Answers (1)

Matt J
Matt J on 22 Apr 2021
Edited: Matt J on 22 Apr 2021
Assuming b is known, the log-model
log(yData)=log(c) + a*(log(x)*sin(x*b)^2)
is a linear model in a and log( c ). Therefore, if you know a decent guess for b, you can use a linear fit (which doesn't require an initial guess) to develop initial guesses for the other parameters.
  2 Comments
hamzah almadani
hamzah almadani on 23 Apr 2021
thank you for your answer, but how I can solve the equation ?
Matt J
Matt J on 23 Apr 2021
For example,
p=polyfit( (log(x)*sin(x*b)^2) , log(yData), 1 );
a=p(1);
c=exp(p(2))

Sign in to comment.

Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!