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
 LabTalk Forum
 smoothing function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

anje18

USA
9 Posts

Posted - 07/23/2002 :  09:37:22 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
How do I access the Savitsky-Golay smoothing function from LabTalk?

CStorey

Canada
137 Posts

Posted - 07/23/2002 :  10:26:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You would do something like the following....

[SGsmoother]

curve.data$=%(%V,2); // name of solumn to smooth
curve.result$=%(%V,4); // name of column for smoothed data
curve.polydeg=2; // degree of polynomial
curve.smoothPts=21; // # of points to use in smooth, or set R/L below
// curve.smoothLeftPts=NumLPts; // Points left of
// curve.smoothRightPts=NumRPts;
curve.i1=-1; // start smoothing from first point (-1) or any point (>1)
// curve.derivdeg=1; // S-G derivative degree, for S-G derivatives
curve.sgsmooth(); // Perform smoothing

Hope this helps!


Craig Storey
Origin WebRing Member - http://g.webring.com/hub?ring=originwebring
Go to Top of Page

anje18

USA
9 Posts

Posted - 07/23/2002 :  1:32:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your help. I have written the following code into a LabTalk .ogs file:

def savitsmooth
{
curve.data$=%(%V,2);
curve.result$=%(%V,4);
curve.polydeg=2;
curve.smoothPts=21;
curve.i1=-1;
curve.sgsmooth();
}

Now I am wondering if this coding is correct and if so, how do I compile and run this function in Origin.
Go to Top of Page

CStorey

Canada
137 Posts

Posted - 07/23/2002 :  1:52:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello again,

Origin does not have a compiler, OriginC code is built either on execution or at start-up and LabTalk is interpretted.

Since you've chosen LabTalk you can run the script a bunch of ways: associate it with a button, a menu item, from a dialog, script window, editor, marco, section.... I suggest you read the Help files on running LabTalk scripts.

The code as you have written it is correct, but will not work unless you specify the following two line somehow.

curve.data$=%(%V,2);
curve.result$=%(%V,4);

The %(%V,x) notation is called substitution notation and in this case it is used to select the column from the worksheet name stored in variable %V. So you will have to define %V as the graph you are going to work with. You might even want to add a new column for the results rather then column #4.

Eg. %V=Graph1;

I suggest you create a graph with your data called Graph1 and test the results. (21 points might be too many or too few for your data.) Copy and paste teh following in the script window and execute it, highlight the code and press enter, to test. If it all looks ok then start looking at a more permanent solution.

%V=Graph1;
curve.data$=%(%V,); // fill this in!
curve.result$=%(%V,); //fill this in!
curve.polydeg=2;
curve.smoothPts=21;
curve.i1=-1;
curve.sgsmooth();

If you encounter problems post your results.


Craig Storey
Origin WebRing Member - http://g.webring.com/hub?ring=originwebring
Go to Top of Page

anje18

USA
9 Posts

Posted - 07/24/2002 :  09:06:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you again. I have written this into LabTalk:

def savitsmooth
{
%V=PHILBIN1;
curve.data$=%(%V,EMG); // fill this in!
curve.result$=%(%V,C); //fill this in!
curve.polydeg=2;
curve.smoothPts=21;
curve.i1=-1;
curve.sgsmooth();
}

but I am still a bit confused about how to call this macro in Origin. Could you possibly help me with this?
Go to Top of Page

CStorey

Canada
137 Posts

Posted - 07/24/2002 :  12:30:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

The easiest way is to do this is as follows. (Please read the info contained here for more details on running LabTalk scripts - http://www.genevalake.ca/origin/origin_intro.html)

- Look on the origin tool bar for an icon with 3 connected squares in a traingular pattern. Click on it. A message box should appear saying this icon can be used to run your own code if you modify custom.ogs. That's waht we'll do.
- Open the custom.ogs file in the Origin directory.
- Look under the heading [Main] and delete everything there, but leave the heading.
- Add the following code...

curve.data$=PHILBIN1_EMG;
curve.result$=PHILBIN1_C;
curve.polydeg=2;
curve.smoothPts=21;
curve.i1=-1;
curve.sgsmooth();
Return;

- save the file.
- Click on the button and the smoothing should happen.

Note that I changed the way the data columns identified. As you had written it nothing would have happened. %Substitution requires a number to be specified, not the column name.

Good luck.

Craig Storey
Origin WebRing Member - http://g.webring.com/hub?ring=originwebring
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