0
votes

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.

1
How is this different from your previous question on the subject? - Dev-iL

1 Answers

0
votes

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.