-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

GNU Octave Beginner's Guide
By :

1. Assume that we have loaded the relevant data into Octave and stored the leaf lengths of tree A and B in variables yA
and yB
. The corresponding heights are stored in xA
and xB
.
2. To fit the linear model to the data in yA
, we do the following:
octave:15> [cA sA] = polyfit(xA, yA, 1);
3. We must check if the fit made any sense at all. First, we can plot the resulting linear fit together with the data:
octave:16> plot(xA, yA, 'rs', xA, sA.yf, 'r');
and is shown in the figure below with red squares and a red line.
4. The fit of y B to the third order polynomial follows the same procedure:
octave:17> [cB sB] = polyfit(xB, yB, 3); octave:18> hold on; plot(xB, yB, 'bv', xB, sB.yf, 'b');
The plot is shown in the figure below:
![]() |
Notice that I have used the plotting style format'rs'
and'bv'
. Depending on your plotting backend, this may not be supported. You can change it to, for example,'ro'
and'b+'
polyfit
finds the polynomial coefficients...
Change the font size
Change margin width
Change background colour