How can I use the polytfit at function A^2=5*b*y?

1 view (last 30 days)
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,

Accepted Answer

Image Analyst
Image Analyst on 12 Dec 2015

More Answers (1)

John D'Errico
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
ahmet kuzucanli
ahmet kuzucanli on 12 Dec 2015
I have to use the polyfit function . It is necessary. As b values changes and I should plot the change in b and requirement in this problem is actually fitting. Do you have any other idea? By the way thanks for answer.
John D'Errico
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!