The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 plotting polynoms

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ovince 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
3   L A T E S T    R E P L I E S    (Newest First)
Mike Buess 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
ovince 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 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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000