fit a curve and equation
1 view (last 30 days)
Show older comments
Hello,
I have 2 points (x1,y1) and (x2,y2) and wanna fit the power curve with the following shape: sigma=a.x^b+c
and also I know that the b= - 0.5
after fitting I wanna know the value of a and c.
I'll be appreciated if you could help.
best
0 Comments
Accepted Answer
Star Strider
on 2 Apr 2019
Since you know ‘b’, your system is linear.
This works:
x = [x1 x2];
y = [y1 y2];
B = [x(:).^(-0.5) ones(2,1)] \ y(:);
a = B(1)
c = B(2)
You could also use polyfit.
2 Comments
Star Strider
on 2 Apr 2019
Your model is linear. the partial derivative of your objective function with respect to each parameter is not a function of that parameter or any other parameter. That is the definition of ‘linear’ in this context, in that your model is linear in the parameters.
Example —
x = rand(2,1)
y = rand(2,1)
Bnonlin = fminsearch(@(b) norm(y - (b(1)./sqrt(x) + b(2))), [1; 1])
Blin = [x(:).^(-0.5) ones(2,1)] \ y(:)
The estimated parameters from both are essentially the same, allowing for the iteratrive estimation used in fminsearch.
It would not be linear if you were also estimating ‘b’. However you could not uniquely estimate three parameters from two data points regardless of the method you chose.
More Answers (0)
See Also
Categories
Find more on Mathematics and Optimization 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!