Repository URL to install this package:
|
Version:
4.4.5.dfsg-3ubuntu2 ▾
|
<HTML>
<HEAD>
<TITLE>Fit a function</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<p>
Read in some x-y data and then find a least-squares fit to the data as a linear
combination of given functions, or as a nonlinear function.</P>
<P>
Read in arrays <code>x</code> and <code>y</code> from
<a href="BasicTasksS11D01.dat">xyL.dat</a> and find the best 5th degree polynomial fit</P>
<P>
<font color="blue"><pre>
read xyL.dat x y
scalar\fit a0 a1 a2 a3 a4 a5
fit y = a0+a1*x+a1*x^2+a2*x^3+a3*x^4+a4*x^5
</pre></font></P>
<P>
<img src="BasicTasksS11I01.gif"></P>
<P>
Read in arrays <code>x</code> and <code>y</code> from <a href="BasicTasksS11D02.dat">xyN.dat</a>
and find the best fit to <code>y(x) = a0*exp(a1*x)*sin(a2*x+a3)</code></P>
<P>
<font color="blue"><pre>
read xyN.dat x y
scalar\fit a0 a1 a2 a3
a0 = 5
a1 = -.5
a2 = 1.5
a3 = .5
fit y = a0*exp(a1*x)*sin(a2*x+a3)
</pre></font></P>
<P>
<img src="BasicTasksS11I02.gif"></P>
<P>
<a href="BasicTasksS10.htm"><img src="../shadow_left.gif">
<font size="+1" color="olive">Read data from files</font></a><br />
<a href="BasicTasksS12.htm"><img src="../shadow_right.gif">
<font size="+1" color="olive">Define and plot a function</font></a></P>
</BODY>
</HTML>