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

Stefan.E.S

Germany
11 Posts

Posted - 02/18/2010 :  06:41:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver.8.1 and Service Release 1(Select Help-->About Origin):
Operating System: WinXP

I am trying to perfom a fft_lowpass filtering of using Origin C using the following lines of code


	Dataset TOF(wksData,wksData.Columns("TOF").GetIndex());
	Dataset PHonIon(wksData,wksData.Columns("PHonIon").GetIndex());
	Dataset PHoffIon(wksData,wksData.Columns("PHoffIon").GetIndex());
	Dataset PHonIoff(wksData,wksData.Columns("PHonIoff").GetIndex());
	Dataset Signal(wksData,wksData.Columns("Signal").GetIndex());
	Dataset FFTtof(wksData,wksData.Columns("FFTtof").GetIndex());
	Dataset FFTsig(wksData,wksData.Columns("FFTsig").GetIndex());
	
	int npts = PHonIon.GetSize();
	Signal.SetSize(npts);

	int nptsFFT = 1;
	while (nptsFFT<npts) nptsFFT*=2; // FFT requires the number of points being equal a power of 2
	vector FFTx, FFTy;
    FFTtof.SetSize(nptsFFT);
    FFTsig.SetSize(nptsFFT);
    
	for (int n=0; n<npts; n++)
	{
		Signal[n] = -PHonIon[n]+PHoffIon[n]+PHonIoff[n]; // these are the data to be filtered
		FFTtof[n] = TOF[n];
		FFTsig[n] = Signal[n];
	}
	double dt = TOF[1]-TOF[0];
	for (n=npts;n<nptsFFT;n++)
	{
		FFTtof[n] = FFTtof[n-1]+dt;
		FFTsig[n] = 0.0;
	}

	Curve FFTcurve(FFTtof,FFTsig);
    int ierr = fft_lowpass(FFTcurve,2e7);
    if (ierr>0)
    {
    	string messagestr;
    	messagestr.Format("ERROR: FFT returned error code %d",ierr);
    	MessageBox(NULL,messagestr);
    }    
    FFTtof.SetSize(npts);
    FFTsig.SetSize(npts);



It appears that the data in the worksheet columns "FFTtof" and "FFTsig" are not changed by fft_lowpass. What am I doing wrong?

Penn

China
644 Posts

Posted - 03/09/2010 :  02:29:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There are two prototypes for fft_lowpass function.

int fft_lowpass(Curve& crvSignal, double dFc);
int fft_lowpass(vector& vecSignal, double dFc, vector* vecTime=NULL);

In your code, you are using the first one. However, we have tried this one and found a bug. We will fix this bug in the future version. For now, you can use the second one.

Penn
OriginLab Technical Services
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