[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Curve Fitting and Plotting
From: |
Ben Abbott |
Subject: |
Re: Curve Fitting and Plotting |
Date: |
Fri, 26 Sep 2008 07:12:24 -0400 |
On Sep 26, 2008, at 6:32 AM, Kearan Mc Pherson wrote:
Hi
I am new to Octave and Gnuplot. I need help on fitting a curve
through a data.dat file, that contains values x an y in column format.
Any ideas where to start?
Kind regards
If the data is in two columns, and you'd like a simple polynomial
fit ...
## Load the data into (x,y)
data = load ('data.dat');
xdata = data(:,1);
ydata = data(:,2):
## Fit a 2nd order polynomial
order = 2;
p = polyfit (xdata, ydata, order);
## Evaluate the fitted polynomial
x = linspace (min(xdata), max(xdata), 101)
y = polyval (p, x);
## Plot
plot (x, y, '-' xdata, ydata, 's')
legend ('Fitted polynomial', 'Original Data')
Ben
- Curve Fitting and Plotting, Kearan Mc Pherson, 2008/09/26
- Re: Curve Fitting and Plotting, David Bateman, 2008/09/26
- Re: Curve Fitting and Plotting, Stefano Mandelli, 2008/09/26
- Re: Curve Fitting and Plotting,
Ben Abbott <=
- Re: Curve Fitting and Plotting, Fredrik Lingvall, 2008/09/26
- Re: Curve Fitting and Plotting, Kearan Mc Pherson, 2008/09/29
- Re: Curve Fitting and Plotting, Jaroslav Hajek, 2008/09/29
- Re: Curve Fitting and Plotting, Kearan Mc Pherson, 2008/09/29
- Re: Curve Fitting and Plotting, Jaroslav Hajek, 2008/09/29
- Re: Curve Fitting and Plotting, Kearan Mc Pherson, 2008/09/29
- Re: Curve Fitting and Plotting, Jaroslav Hajek, 2008/09/29
- Re: Curve Fitting and Plotting, Carlo de Falco, 2008/09/29
Re: Curve Fitting and Plotting, Michael Creel, 2008/09/26