Need help writing a code
Show older comments
Hello community, this is a problem I have as homework, I have been looking for a way to write this code but I am not sure how to go about this. I am not the best in matlab and need some help. If someone can help me to solve this it would be much appreciated.

Answers (1)
Roger Stafford
on 28 Apr 2015
0 votes
It would be easy to write the code for this problem, or even to just mention certain matlab functions that would do the job easily for you. However, in my opinion, you will learn the most by working this out for yourself - with a little hint to get you going.
Here is the hint: First, you should determine what it means to do a "least squares fit". What is it that is to be least? After you have written an expression that is to be minimized for least squares fit, you can obtain ten different equations by taking the partial derivatives of that expression with respect to the ten different coefficients and setting each derivative to zero. When you do, you will have ten linear equations in ten unknowns. Solving such equations using matrices is what matlab is all about. Good luck!
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!