Matlab Linearization: Best Approximation Using Polyfit

  • Context: MATLAB 
  • Thread starter Thread starter IlyaZ
  • Start date Start date
  • Tags Tags
    Linearization Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 16K views
IlyaZ
Messages
15
Reaction score
0
Hello,

this is my situation: I've got some data from an experiment stored in matlab. So I plot the graph and get a x^2 curve. I plot the loglog graph and see a near-"perfect" line. Now I want to create the best approximation to it (in a least squares sense).

I don't want to do that manually as it's a tedious process. So I tried polyfit, but when I compare the line generated by polyfit to the line from the experiments + after applying loglogging it doesn't match at all.

I take it I made something wrong, but I don't get what. :cry:
 
Physics news on Phys.org
Try polyfitting the log values of the data you obtained, instead of polyfitting the actual values and then plotting the log plot thereafter. If that doesn't work, then show the data you obtained and the Matlab code you used here. That helps in pinpointing where you go wrong.

Btw, I think this thread is more relevant in the Homework section.
 
Thanks for your reply I think it solved the problem.