Register to reply

Curve fit in MATLAB

by ACLerok
Tags: curve, matlab
Share this thread:
ACLerok
#1
Dec10-07, 09:45 PM
P: 195
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?
Phys.Org News Partner Science news on Phys.org
Flapping baby birds give clues to origin of flight
Prions can trigger 'stuck' wine fermentations, researchers find
Socially-assistive robots help kids with autism learn by providing personalized prompts
chroot
#2
Dec10-07, 11:50 PM
Emeritus
Sci Advisor
PF Gold
chroot's Avatar
P: 10,427
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
ACLerok
#3
Dec11-07, 09:24 AM
P: 195
will i be able to enter in my own custom equation? thanks

unplebeian
#4
Dec13-07, 10:00 AM
P: 137
Curve fit in MATLAB

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.
f95toli
#5
Dec13-07, 12:07 PM
Sci Advisor
PF Gold
f95toli's Avatar
P: 2,250
Quote Quote by ACLerok View Post
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.
F.Moisy
#6
Mar14-08, 06:10 AM
P: 1
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.


Register to reply

Related Discussions
Curve fitting in Matlab Math & Science Software 1
MATLAB help: determining the area under a plot (not a curve whose form is known) Math & Science Software 4
Curve fitting using Matlab Math & Science Software 0
Create bezier curve from 2 conected curve General Math 2
Differential Geometry: Showing a curve is a sphere curve Calculus & Beyond Homework 0