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
 LabTalk Forum
 A script to filter (Bandpass)

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
thomas-brunet Posted - 11/30/2005 : 08:29:35 AM
Origin Version (Select Help-->About Origin):
Operating System:

Hello !

I would like to make a script to filter (bandpass: 20kHz-30kHz) several signals. First, how could I filter a signal with a labtalk script with "ftt_bandpass(curve..., DFlow,DFhigh)" ?
The worksheet's name is "data1" and contains two columns. First one is "time(X)" and the second one "A(Y)" corresponding to the signal. After, I would like to use this script to filter automatically many columns (B(Y), C(Y), D(Y),..).
Thank you very much!

Thomas.
2   L A T E S T    R E P L I E S    (Newest First)
thomas-brunet Posted - 12/01/2005 : 10:34:01 AM
Thank you very much for your help, it works nice !
Mike Buess Posted - 11/30/2005 : 1:45:40 PM
Hi Thomas,

I'm not sure OriginC's fft_bandpass() function is fully implemented in Origin 7.5 but the following approach seems to work in SR5...

1. Open CodeBuilder and select File > New.
2. Select C File on the list at left.
3. Check the Add to Workspace and Fill with Default Contents options.
4. Enter a filename and path, then click OK.
5. Insert #Include <fft_utils.h> under the line #Include <Origin.h> near the top of the new file.
6. Scroll to the bottom, enter a new line and paste the following bandpass filter function to the file.
7. Select File > Open, check the Add to Workspace option at the bottom of the dialog and open the file fft_utils.c in the OriginC\OriginLab subfolder on Origin's program path.
8. Select Tools > Rebuild All to compile. If you get a compiler error apply the SR5 patch and try again.
9. Close CodeBuilder and execute by typing run_fft_bandpass(dFLow, dFHigh) in the script window and pressing Enter. (dFLow and dFHigh are the low and high cutoff frequencies.) The function will filter all Y columns in the active worksheet.
// Bandpass filter for LabTalk
int run_fft_bandpass(double dFLow, double dFHigh)
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("A worksheet must be active.");
return 1;
}
int iErr;
for(int i=1;i<wks.GetNumCols();i++)
{
if(wks.Columns(i).GetType()==OKDATAOBJ_DESIGNATION_Y)
{
Curve crv(wks,i);
iErr = fft_bandpass(crv, dFLow, dFHigh);
if(iErr<0) break;
}
}
switch(iErr)
{
case -3:
out_str("Invalid cutoff frequency.");
break;
case -2:
out_str("Invalid curve.");
break;
case -1:
out_str("Curve does not meet time resolution criterion.");
default:
break;
}
return iErr;
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/30/2005 1:49:39 PM

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