| Author |
Topic  |
|
|
ovince
Yugoslavia
Posts |
Posted - 11/20/2006 : 07:30:11 AM
|
hi,
Using a fitpoly() method, I got the coefficents of 2nd order polynom
Curve crv(x,y); double coeff[2]; bool bRet=fitpoly(crv, 1, coeff);
Can I use them to overplot the polynom over the (already existing) graph and how?
Thanks Oliver |
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/20/2006 : 08:24:10 AM
|
Hi Oliver,
Create a new column in the wks containing x and y. Fill column with values of the polynomial. Plot column in existing layer.
int colNum = wks.AddCol(); Dataset dx(wks,0); // X dataset Dataset dy(wks,colNum); // Y dataset for(int i=0; i<dx.GetSize(); i++) { dy[i] = coeff[0] + coeff[1]*dx[i]; } Curve crv(wks,colNum); gl.AddPlot(crv,IDM_PLOT_LINE); // gl is existing graph layer
Mike Buess Origin WebRing Member |
 |
|
|
ovince
Yugoslavia
Posts |
Posted - 11/20/2006 : 09:35:30 AM
|
thanks Mike
something strange is happening in the for loop
int colNum = wks.AddCol(); Dataset dx(wks,0); // X dataset Dataset dy(wks,colNum); // Y dataset for(int i=0; i<dx.GetSize(); i++) { printf("%f\t %f\t %f\n", coeff[0], coeff[1], dx[i]); dy[i] = coeff[0] + coeff[1]*dx[i]; }
Although, all values (coeff[0], coeff[1], dx[i])) are defined inside the loop (checked with print() ) dy[i] is not calculated. I have tried with changing the name dy[i] -> dyy[i] to be sure it does not exist but does not help
have any idea what to do?
oliver |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/20/2006 : 09:50:42 AM
|
Try setting the size of dy before setting its values...
int colNum = wks.AddCol(); Dataset dx(wks,0); // X dataset Dataset dy(wks,colNum); // Y dataset dy.SetSize(dx.GetSize());
Mike Buess Origin WebRing Member |
 |
|
| |
Topic  |
|
|
|