Matlab Linearization: Best Approximation Using Polyfit

  • Context: MATLAB 
  • Thread starter Thread starter IlyaZ
  • Start date Start date
  • Tags Tags
    Linearization Matlab
Click For Summary
SUMMARY

The discussion focuses on using MATLAB's polyfit function for approximating experimental data that follows a quadratic trend. The user initially attempted to apply polyfit directly to the raw data but found that the resulting approximation did not align with the log-log plot of the data. The solution provided suggests applying polyfit to the logarithmic values of the data instead, which is crucial for achieving a better fit in a least squares sense. The user confirmed that this approach resolved their issue.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of polynomial fitting techniques
  • Knowledge of logarithmic transformations
  • Basic concepts of least squares approximation
NEXT STEPS
  • Learn how to implement MATLAB's polyfit function effectively
  • Explore techniques for data transformation, specifically logarithmic scaling
  • Study least squares fitting methods in MATLAB
  • Investigate the use of log-log plots for data analysis
USEFUL FOR

Researchers, data analysts, and engineers who are working with experimental data in MATLAB and need to perform polynomial approximations for better data representation.

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.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
8K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K