How can I use the polytfit at function A^2=5*b*y?
1 view (last 30 days)
Show older comments
ahmet kuzucanli
on 12 Dec 2015
Edited: John D'Errico
on 12 Dec 2015
Hi, everyone. I want to use the polyfit command to determine the experimental value of b. I have the values of A and y. y = [0 3 7 20 23 24]; A = [0 9.85 16.42 19.63 21.34 24.41]; But I could not handle using polyfit function for it. How can I determine the b values by using polyfit? Regards,
0 Comments
Accepted Answer
Image Analyst
on 12 Dec 2015
ahmet, follow this link to the official Mathworks answer: http://www.mathworks.com/matlabcentral/answers/94272-how-do-i-constrain-a-fitted-curve-through-specific-points-like-the-origin-in-matlab
0 Comments
More Answers (1)
John D'Errico
on 12 Dec 2015
Edited: John D'Errico
on 12 Dec 2015
You can't use polyfit, since there is no constant term. There are several tools on the file exchange that can do it, my own polyfitn included, and there are tools in the stats toolbox, or you could use lscov. However, there is a far easier way to do it, requiring no special tool to be downloaded, and no toolbox. Use backslash.
y = [0 3 7 20 23 24];
A = [0 9.85 16.42 19.63 21.34 24.41];
b = y'\A'.^2/5
b =
4.43500620601407
2 Comments
John D'Errico
on 12 Dec 2015
Edited: John D'Errico
on 12 Dec 2015
Sigh. No, you DON'T have to use polyfit, as polyfit is not possible to use when you have no constant term in the model. So polyfit is not necessary, since it cannot be used for this problem.
The result from backslash that I provided is indeed the LEAST SQUARES solution. It is as good as that which any other tool would provide. Just wanting software to solve a problem it cannot solve is not enough. There is no way to trick polyfit into working in this case. That is irrelevant, since as I said, the backslash solution is indeed a least squares solution.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!