Date: Feb 23, 2013 9:01 PM
Author: dpb
Subject: Re: Polyfit data

On 2/23/2013 1:42 PM, Ryan Pelky wrote:
> I have a set of data which is 19 rows by 2 columns. I'm trying to run a
> for loop to plot polyfit lines of different orders (1:7) here is what I
> came up with.
> %polyfit problem
> clear;clc;
> load('dota.mat')
> x=1:.01:20;
> for(i=1:7)
> coef=polyfit(dota(:,1),dota(:,2),i)

> yfit=coef(i+1)+coef(i)*x.^i;

A seventh order polynomial is likely to be highly noisy for real data
but above may be only for tutorial purposes...

They're aren't enough coefficients for a fixed evaluation as above and
you'll have wiped out the coef() array w/ a new order the second and
subsequent times thru, anyway...

doc polyval