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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 smooth
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ovince

Yugoslavia
Posts

Posted - 01/10/2007 :  02:55:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi,

Happy New Year first of all to everybody :)))))

I tryed to smooth curve like this:

Curve crv(wksNew, 0, 1);
BOOL bErr = smooth(crv, 0, 100, 100);

int k = gly.AddPlot( crv, IDM_PLOT_LINE );
DataPlot dpLine = gly.DataPlots(k);
dpLine.Curve.Line.Color.nVal = k;

gly.Rescale();

This should adjecent average taking 200 points into accout. Have any idea why result obtained in this way differ from the result I get in Origin using Analysis/Smoothing/Adjecent Averaging option?

thanks
regards
oliver

Mike Buess

USA
3037 Posts

Posted - 01/10/2007 :  07:27:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

The Origin C smooth settings are somewhat misleading. For adjacent averaging the first point argument is actually the total number of points used for averaging and the second argument is ignored. So smooth(crv,0,100,100) takes a total of 100 (actually 101) points into account.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/10/2007 07:28:55 AM
Go to Top of Page

ftalbot

France
Posts

Posted - 02/21/2007 :  03:53:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
I also have a problem with that "smooth" command.
I use Origin 7.5 SR6 on WinXP+SP2.
Here is a part of my code:
....
icolavg = wks.AddCol("avg");
Column col_avg(wks, icolavg);
Column coly(wks, 1);
col_avg=coly;
Curve crv(wks,icolavg);
BOOL bErr=smooth(crv,2,10);
....
Where I'm trying to add a new column to the worksheet with a smoothed version (I call it "avg") of my data column.
It compiles fine but when I execute the thing I get:
"Origin C Function Runtime Error, LabTalk command failed"
And it refers to my line:
"BOOL bErr=smooth(crv,2,10);"
So, even if I follow the corrected syntax, it still doesn't work.
Am I doing something wrong?
What is the CORRECT syntax for that command?

Francis.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/21/2007 :  09:27:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Francis,

The problem is that col_avg=coly does not copy the values from coly to col_avg. Try this...

Worksheet wks = Project.ActiveLayer();
int icolavg = wks.AddCol("avg");
Curve crvy(wks,1);
Curve crvavg(wks,icolavg);
crvavg = crvy;
BOOL bErr=smooth(crvavg,2,10);

...Also, when 2nd argument is 2 Savitzky-Golay filtering is used rather than Adj Averaging. In that case all arguments are used and your command is equivalent to smooth(crvavg,2,10,3,2). That is, left points = 10, right points = 3, polynomial degree = 2. Is that what you want?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 02/21/2007 11:12:39 AM
Go to Top of Page

zachary_origin

China
Posts

Posted - 02/26/2007 :  9:57:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Francis,

Other than what Mike has mentioned, I want to supplement something else: avoiding to use Column for a Dataset as class Column object is primarily used for style related control of the data in the associated Dataset. To do the calculation for the columns, you need use Dataset for the column, which merely contains the data of the columns.

You can try to replace the keyword "Column" with "Dataset" in your code, it will work fine.



Zachary
OriginLab Technical Services.



Edited by - zachary_origin on 02/26/2007 9:58:04 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000