Fitting a Curve to Data: MATLAB vs Excel

In summary, There are multiple ways to fit a curve to a set of data in MATLAB, including using the curve fitting tool in the plot window or writing custom code. Excel also has a built-in curve fitting feature, which may be easier to use for simple polynomial fits. Additionally, there is a free curve fitting toolbox for MATLAB called Ezyfit.
  • #1
ACLerok
194
0
I have a set of data and I need to fit a curve to it. The equation of the curve is:
y=20-a*10*log(x)
My problem is just getting a curve fit to this equation. What function in MATLAB should I be looking for? How do I get the value of 'a'?

Is it easier to achieve this in Excel? How?
 
Physics news on Phys.org
  • #2
Plot it, and then look in the menus in the plot window for a fitting tool.

All of the functions available in that menu are also available on the command line, but I find curve fitting to be much more intuitive when done in a plot window.

- Warren
 
  • #3
will i be able to enter in my own custom equation? thanks
 
  • #4
In excel if you have all the points plotted out, it will curve fit the points to whatever order of polynomial you want.

In Matlab I am sure you can enter your custom equations.
 
  • #5
ACLerok said:
will i be able to enter in my own custom equation? thanks

Yes, you can fit to whatever function you want.
Note that if you use functions from the Optimization toolbox (if you have that installed) you can quite easily fit to a nonlinear Matlab function, i.e. you can "fit" to a piece of code which generates an output that depends on an number of inputs, even if the function includes e.g. interpolation (which is often used conventient when fitting to a large set of experimental data), if-then statements etc. This is often very useful.

Also, if you are able to rewrite your equations as a matrix equation (e.g. a sum of exponentials with unknown prefactors) you can of course also solve it directly, i.e. using something like "X\b" which gives you the best result in the least-square sense.
 
  • #6
Fit in matlab

You can also try Ezyfit, a free curve fitting toolbox for Matlab:
www.fast.u-psud.fr/ezyfit
In your case just type
showfit('y=20-a*10*log(x)')
if your data are plotted in a figure, or
f = ezfit(x,y,'y=20-a*10*log(x)')
if your data are stored into the vectors x,y.
 

1. What is the main difference between using MATLAB and Excel for fitting a curve to data?

The main difference is that MATLAB is a programming language specifically designed for numerical computations and data analysis, while Excel is a spreadsheet software primarily used for data organization and basic calculations. This means that MATLAB has more advanced and customizable tools for curve fitting, while Excel has more limited and basic features.

2. Which program is better for fitting a curve to data, MATLAB or Excel?

The answer to this question depends on the specific needs and preferences of the user. If the user is familiar with programming and requires more advanced curve fitting techniques, MATLAB may be a better choice. However, if the user is more comfortable with a user-friendly interface and needs basic curve fitting capabilities, Excel may be a better option.

3. Can both MATLAB and Excel handle large datasets for curve fitting?

Yes, both programs can handle large datasets for curve fitting. However, MATLAB may be more efficient for handling larger datasets as it is a programming language designed for data analysis, while Excel may experience slower performance with very large datasets.

4. Are there any limitations to using Excel for curve fitting?

Yes, there are some limitations to using Excel for curve fitting. Excel has a limited set of curve fitting functions and may not be able to handle more complex curve fitting techniques. It also has a limit on the number of data points that can be used for curve fitting.

5. Do I need to have programming experience to use MATLAB for curve fitting?

While having some programming experience may be helpful, it is not necessary to use MATLAB for curve fitting. There are many tutorials and resources available online that can guide beginners through the process of using MATLAB for curve fitting.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
975
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
798
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
865
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top