Fitting a Curve to Data: MATLAB vs Excel

Click For Summary

Discussion Overview

The discussion revolves around fitting a curve to a specific equation using MATLAB and Excel. Participants explore methods for achieving this fit, including the use of custom equations and available tools in both software environments.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about the appropriate MATLAB function for fitting the curve defined by the equation y=20-a*10*log(x) and asks whether Excel might be easier for this task.
  • Another participant suggests using the plot window in Excel to access fitting tools, noting that these functions are also available via the command line.
  • There is a question about the ability to enter custom equations in both MATLAB and Excel, with responses indicating that both platforms allow for this capability.
  • A participant mentions that MATLAB's Optimization toolbox can facilitate fitting to nonlinear functions, including those that involve complex structures like interpolation or conditional statements.
  • Another suggestion includes using Ezyfit, a free toolbox for MATLAB, providing specific commands for fitting the discussed equation to the data.

Areas of Agreement / Disagreement

Participants generally agree that both MATLAB and Excel can be used for curve fitting, including the use of custom equations. However, there is no consensus on which platform is definitively easier or more effective for this specific task.

Contextual Notes

Some limitations include the need for specific toolboxes in MATLAB, such as the Optimization toolbox, and potential dependencies on the definitions of the equations used for fitting.

Who May Find This Useful

This discussion may be useful for individuals interested in data analysis, curve fitting techniques, and the comparative capabilities of MATLAB and Excel in handling custom equations.

ACLerok
Messages
194
Reaction score
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
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
 
will i be able to enter in my own custom equation? thanks
 
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.
 
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.
 
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.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K