0

I am trying to fit an equation to the data, i am using polyfit but it is not close enough. I also dont have curve fitting toolbox. Here is the code and picture:

p2 = polyfit(xDat,zDat,2);
f2 = polyval(p2,xDat);


figure;
plot(xDat,zDat,'.r');
hold on
plot(xDat,f2,'*b');

enter image description here

Red dots is data and Blue points is the fit.

nman84
  • 335
  • 3
  • 8
  • 25
  • How is this different from [your previous question](http://stackoverflow.com/q/40160257/3372061) on the subject? – Dev-iL Mar 22 '17 at 20:29

1 Answers1

0

It looks like you are using a second order (quadratic) polynomial:

p2 = polyfit(xDat,zDat,2);

I suggest testing higher order polynomials as in:

p2 = polyfit(xDat,zDat,3);
p2 = polyfit(xDat,zDat,4);
p2 = polyfit(xDat,zDat,5);

and see if one of those might work.

James Phillips
  • 4,526
  • 3
  • 13
  • 11