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
 why i got different results?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

mynameisok

China
Posts

Posted - 03/31/2007 :  09:03:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):Origin pro 7.5 sr5
Operating System:xp


i used two methods to give on the same Dataset lowpass frequency cutoff.

one is using the menu of origin,the other is fft_lowpass(),and the Fc was the same .

but the results are different.So is bandpass.

sorry for my poor english.

i cannot figure out what happened.

here is my oc code
 


int run_fft_lowpass(double dFc)
{


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_lowpass(crv, dFc);
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

USA
3037 Posts

Posted - 03/31/2007 :  10:08:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
How do the results differ?

Mike Buess
Origin WebRing Member
Go to Top of Page

mynameisok

China
Posts

Posted - 03/31/2007 :  10:47:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
the fft_lowpass result seems unchanged,but iErr=0 ,there is no warning.


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/31/2007 :  11:42:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
the fft_lowpass result seems unchanged,but iErr=0 ,there is no warning.
Doesn't that just mean there is nothing above the cutoff frequency that needs to be filtered out? Try lowering Fc.

Lowpass filtering from the menu sets the number of points to a power of two whereas the OC method does not. Results are the same when the point count of the original data is a power of two.

Mike Buess
Origin WebRing Member
Go to Top of Page

mynameisok

China
Posts

Posted - 04/02/2007 :  06:47:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ah!

i finally understand what is "power of 2"

but how can i set Number of points if i wanna use fft_lowpass()?

by "vecSignal.SetSize(nPts)"?

if original signal size is smaller than nPts ,the end of signal will be filled with zero.

then i can get the same result using fft_lowpass()

is that right?


i'm reading FFTUsingNAG.c .

it's very helpful!

thanks a lot ,Mike!

Edited by - mynameisok on 04/02/2007 07:21:30 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/02/2007 :  08:38:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
but how can i set Number of points if i wanna use fft_lowpass()?
crv.SetSize(npts) will change the number of points by truncating (if npts<current pts) or adding missing values '--' (if npts>current size). (You must change the missing values to zeros in the latter case.) However, it's not trivial to determine whether the FFT Filter menu command pads or truncates...
http://www.originlab.com/www/support/resultstech.aspx?ID=570&language=English&Version=7.5

If you just want to compare your function with the menu command I suggest you manually reduce your data size to the next lower power of two. For normal operations I see no point in restricting the number of points to a power of two in your function.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/02/2007 08:43:57 AM
Go to Top of Page

mynameisok

China
Posts

Posted - 04/02/2007 :  09:00:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
i'm just a code builder,my job is to make an auto program to deal with large number of datasets.

they want to get only one result that my final result is exactly the same as the manual operation.

maybe i should work on labtalk to find a way like what "the menu" does.

after lowpass filter,i have fft,smooth and so on,large project for me.

thank you for your advice.

Edited by - mynameisok on 04/02/2007 09:22:53 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/02/2007 :  09:49:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
FFT Low Pass on the menu runs the [LowPass] section of Granaly.ogs. Other FFT filters are in the same file. Since there is no analytical way to determine if the LabTalk commands will pad or truncate I suggest you perform your demonstration with datasets that are already powers of 2.

Mike Buess
Origin WebRing Member
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