DSPRelated.com
Forums

Remove lower frequence

Started by acepsut8 August 17, 2009
Hello all,

having the spectrum of 5 cosine functions I need to remove the lower one, does anybody knows how to do this?

I have tried with moving average and this works correctly in removing task, but I get alterated amplitudes and phases in 4 remaining periods.

What should I use to get removed lower one without problems?

Thanks

Alberto

Here is the code to create 5 cosine functions, I whis to remove Tf.38 from serie12345

Asim=[17, 18, 18.5, 19, 20]; %Amplitudes
Tsim=[22.5, 33, 44.28, 55.27, 66.38]; %Periods
fase=[1.1, 2.2, 3.3, 0.8, 2.7]; %Phases in radians
p=1:2048;
value=0;
Coseno1=0;
Coseno2=0;
Coseno3=0;
Coseno4=0;
Coseno5=0;

Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
Coseno3=Coseno3+Asim(3)*cos(2*pi*1/Tsim(3)*p+fase(3))';
Coseno4=Coseno4+Asim(4)*cos(2*pi*1/Tsim(4)*p+fase(4))';
Coseno5=Coseno5+Asim(5)*cos(2*pi*1/Tsim(5)*p+fase(5))';

serie12345=Coseno1+Coseno2+Coseno3+Coseno4+Coseno5;

%To remove with moving average:

mm6638 = tsmovavg(serie12345, 's', 66.38, 1);
Thank you Jeff for yor reply.

The reason for my request is due to some problems I have found using fourier
transform. All problems it happens when there are 2 or more cycles
clustering (i.e. very close each other, let's suppose 66.38, 67 and 67.22),
also known as beatings.

To correctly resolve all cycles I should use a huge dataset since fourier
transform is not able to find such periodicities.

Problem whithin problem, if one of these cycles has greater magnitude
compared to the others, this greater magnitude acts like an electro-magnetic
fields and it distorts phase, amplitude and periods of its neighbors.

To get as more as possible accurate spectrum, I would like to try to remove
each cycle found,one by one, and each time perform the fourier
transform since I do not know what other cycles could be hidden: if I could
be able to remove exacly the lower one, I could find next close one not seen
previously due to cluster or higher magnitude.

Any suggestion on how to perform this? Or, do you think there are other ways
to do this?

Regards,

Alberto
2009/8/17 Jeff Brower

> Alberto-
>
> > having the spectrum of 5 cosine functions I need to remove the
> > lower one, does anybody knows how to do this?
> >
> > I have tried with moving average and this works correctly in
> > removing task, but I get alterated amplitudes and phases
> > in 4 remaining periods.
> >
> > What should I use to get removed lower one without problems?
>
> You might try a highpass filter, either IIR or FIR. Try adjusting the
> cutoff frequency to be about halfway between
> your lowest and next lowest frequencies.
>
> A running average (or averaging of any type) has more of a lowpass effect.
>
> -Jeff
>
> > Here is the code to create 5 cosine functions, I whis to remove Tf.38
> from serie12345
> >
> > Asim=[17, 18, 18.5, 19, 20]; %Amplitudes
> > Tsim=[22.5, 33, 44.28, 55.27, 66.38]; %Periods
> > fase=[1.1, 2.2, 3.3, 0.8, 2.7]; %Phases in radians
> > p=1:2048;
> > value=0;
> > Coseno1=0;
> > Coseno2=0;
> > Coseno3=0;
> > Coseno4=0;
> > Coseno5=0;
> >
> > Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
> > Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
> > Coseno3=Coseno3+Asim(3)*cos(2*pi*1/Tsim(3)*p+fase(3))';
> > Coseno4=Coseno4+Asim(4)*cos(2*pi*1/Tsim(4)*p+fase(4))';
> > Coseno5=Coseno5+Asim(5)*cos(2*pi*1/Tsim(5)*p+fase(5))';
> >
> > serie12345=Coseno1+Coseno2+Coseno3+Coseno4+Coseno5;
> >
> > %To remove with moving average:
> >
> > mm6638 = tsmovavg(serie12345, 's', 66.38, 1);
Alberto-

> having the spectrum of 5 cosine functions I need to remove the
> lower one, does anybody knows how to do this?
>
> I have tried with moving average and this works correctly in
> removing task, but I get alterated amplitudes and phases
> in 4 remaining periods.
>
> What should I use to get removed lower one without problems?

You might try a highpass filter, either IIR or FIR. Try adjusting the cutoff frequency to be about halfway between
your lowest and next lowest frequencies.

A running average (or averaging of any type) has more of a lowpass effect.

-Jeff

> Here is the code to create 5 cosine functions, I whis to remove Tf.38 from serie12345
>
> Asim=[17, 18, 18.5, 19, 20]; %Amplitudes
> Tsim=[22.5, 33, 44.28, 55.27, 66.38]; %Periods
> fase=[1.1, 2.2, 3.3, 0.8, 2.7]; %Phases in radians
> p=1:2048;
> value=0;
> Coseno1=0;
> Coseno2=0;
> Coseno3=0;
> Coseno4=0;
> Coseno5=0;
>
> Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
> Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
> Coseno3=Coseno3+Asim(3)*cos(2*pi*1/Tsim(3)*p+fase(3))';
> Coseno4=Coseno4+Asim(4)*cos(2*pi*1/Tsim(4)*p+fase(4))';
> Coseno5=Coseno5+Asim(5)*cos(2*pi*1/Tsim(5)*p+fase(5))';
>
> serie12345=Coseno1+Coseno2+Coseno3+Coseno4+Coseno5;
>
> %To remove with moving average:
>
> mm6638 = tsmovavg(serie12345, 's', 66.38, 1);
Alberto-

> The reason for my request is due to some problems I have found using fourier
> transform. All problems it happens when there are 2 or more cycles
> clustering (i.e. very close each other, let's suppose 66.38, 67 and 67.22),
> also known as beatings.
>
> To correctly resolve all cycles I should use a huge dataset since fourier
> transform is not able to find such periodicities.

The key is to use a large FFT size. The link below shows an 18th order FFT magnitude
plot with 66 Hz and 67 Hz sines at 1 kHz sampling rate (time domain data set 1024
pts):

http://www.signalogic.com/images/fft_sine_66_67_resolved.jpg

As you can see, they are resolved (barely). If you reduce the FFT size or increase
the sampling rate then resolution becomes more difficult. Another plot shows the
same signal after a highpass filtered has been applied to remove the 66 Hz sine:

http://www.signalogic.com/images/fft_sine_66_67_hpf.jpg

The key is the filter has to be very sharp. In this case I used an elliptic IIR
filter with following specs:

Fs = 1 kHz
Fc = 66.5 Hz
transition region = 0.5 Hz
stopband atten = 40 dB
ripple = 1 dB

-Jeff

> Problem whithin problem, if one of these cycles has greater magnitude
> compared to the others, this greater magnitude acts like an electro-magnetic
> fields and it distorts phase, amplitude and periods of its neighbors.
>
> To get as more as possible accurate spectrum, I would like to try to remove
> each cycle found,one by one, and each time perform the fourier
> transform since I do not know what other cycles could be hidden: if I could
> be able to remove exacly the lower one, I could find next close one not seen
> previously due to cluster or higher magnitude.
>
> Any suggestion on how to perform this? Or, do you think there are other ways
> to do this?
>
> Regards,
>
> Alberto
> 2009/8/17 Jeff Brower > Alberto-
>>
>> > having the spectrum of 5 cosine functions I need to remove the
>> > lower one, does anybody knows how to do this?
>> >
>> > I have tried with moving average and this works correctly in
>> > removing task, but I get alterated amplitudes and phases
>> > in 4 remaining periods.
>> >
>> > What should I use to get removed lower one without problems?
>>
>> You might try a highpass filter, either IIR or FIR. Try adjusting the
>> cutoff frequency to be about halfway between
>> your lowest and next lowest frequencies.
>>
>> A running average (or averaging of any type) has more of a lowpass effect.
>>
>> -Jeff
>>
>> > Here is the code to create 5 cosine functions, I whis to remove Tf.38
>> from serie12345
>> >
>> > Asim=[17, 18, 18.5, 19, 20]; %Amplitudes
>> > Tsim=[22.5, 33, 44.28, 55.27, 66.38]; %Periods
>> > fase=[1.1, 2.2, 3.3, 0.8, 2.7]; %Phases in radians
>> > p=1:2048;
>> > value=0;
>> > Coseno1=0;
>> > Coseno2=0;
>> > Coseno3=0;
>> > Coseno4=0;
>> > Coseno5=0;
>> >
>> > Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
>> > Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
>> > Coseno3=Coseno3+Asim(3)*cos(2*pi*1/Tsim(3)*p+fase(3))';
>> > Coseno4=Coseno4+Asim(4)*cos(2*pi*1/Tsim(4)*p+fase(4))';
>> > Coseno5=Coseno5+Asim(5)*cos(2*pi*1/Tsim(5)*p+fase(5))';
>> >
>> > serie12345=Coseno1+Coseno2+Coseno3+Coseno4+Coseno5;
>> >
>> > %To remove with moving average:
>> >
>> > mm6638 = tsmovavg(serie12345, 's', 66.38, 1);
>>
>
Alberto-
> I like to show you what I've done so far with my code in Matlab: Let's start with
> creating a cosine serie sum of period 1= 62 and period 2c (for my applications I
> need to use periods rather than freq's).
>

Periods are specified in samples; you are not giving a sampling rate. As I tried to
point out in the examples and waveform displays in my previous e-mail, sampling rate
is crucial to this problem -- you have to know it.

Also, please post to the group, not to me. Other people can help you, too. I'm not
the group. Thanks.

-Jeff
> I like to show you what I've done so far with my code in Matlab: Let's start with
> creating a cosine serie sum of period 1= 62 and period 2c (for my applications I
> need to use periods rather than freq's).
>
> clear all; Asim=[17, 18]; %MagnitudesTsim=[62, 63]; %Periodsfase=[1.1, 2.2];
> %Phases
> p=1:2048;
> value=0;
> Coseno1=0;
> Coseno2=0;
> Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
> Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
>
> serie12=Coseno1+Coseno2; If I perform a DFT on serie12 I will find a single cycle
> period= 62.52. Let's try. serie= serie12;
> step=0.01;
> Tmin=6;
> Tmaxu;
> %Nstart=1;
> %Nend 48;
> A=length(serie);Y=fourier(serie',Tmax,Tmin,step);
> X=Tmin:step:Tmax;
> moduloYs(Y)/(A/2);
> faseY=angle(Y) ;
> subplot(1,2,1);plot(X,moduloY);grid on;subplot(1,2,2);plot(faseY,X);grid on;Now I
> remove this cycle using moving average: mm6252 = tsmovavg(serie12, 's', 62.52, 1);
> First 62 values are NaN and we have to set to zeros to perform DFT on this serie.
> Once done, DFT: serie= mm6252;
> step=0.01;
> Tmin=6;
> Tmaxu;
> %Nstart=1;
> %Nend 48;
> A=length(serie);Y=fourier(serie',Tmax,Tmin,step);
> X=Tmin:step:Tmax;
> moduloYs(Y)/(A/2);
> faseY=angle(Y) ;
> subplot(1,2,1);plot(X,moduloY);grid on;subplot(1,2,2);plot(faseY,X);grid on; What
> we see now is a single cycle periodc, so we have to remove this cycle to discover
> if there are other hidden cycles mm63 = tsmovavg(serie12, 's', 63, 1); Set all NaN
> to zeros and let's perform another DFT on this serie serie= mm63;
> step=0.01;
> Tmin=6;
> Tmaxu;
> %Nstart=1;
> %Nend 48;
> A=length(serie);Y=fourier(serie',Tmax,Tmin,step);
> X=Tmin:step:Tmax;
> moduloYs(Y)/(A/2);
> faseY=angle(Y) ;
> subplot(1,2,1);plot(X,moduloY);grid on;subplot(1,2,2);plot(faseY,X);grid on; This
> time we have another cycle periodb, so our first DFT was displaying an incorrect
> cycle (62.52) ,while real cycles was period1b and period2c and we have been
> able to resolve correctly using moving averages. The main problem in all this
> process is about phase and magnitude (Amplitude), on each DFT neither phase nor
> amplitude was found correctly. Am I doing something wrong? Can you help me with
> some Matlab code in how to use FIR or IIR correctly? Thank you very much Alberto
> 2009/8/17 Jeff Brower Alberto-
>
> > The reason for my request is due to some problems I have found using
> fourier
> > transform. All problems it happens when there are 2 or more cycles
> > clustering (i.e. very close each other, let's suppose 66.38, 67 and
> 67.22),
> > also known as beatings.
> >
> > To correctly resolve all cycles I should use a huge dataset since
> fourier
> > transform is not able to find such periodicities.
> The key is to use a large FFT size. The link below shows an 18th order
> FFT magnitude
> plot with 66 Hz and 67 Hz sines at 1 kHz sampling rate (time domain data
> set 1024
> pts):
>
> http://www.signalogic.com/images/fft_sine_66_67_resolved.jpg
>
> As you can see, they are resolved (barely). If you reduce the FFT size
> or increase
> the sampling rate then resolution becomes more difficult. Another plot
> shows the
> same signal after a highpass filtered has been applied to remove the 66
> Hz sine:
>
> http://www.signalogic.com/images/fft_sine_66_67_hpf.jpg
>
> The key is the filter has to be very sharp. In this case I used an
> elliptic IIR
> filter with following specs:
>
> Fs = 1 kHz
> Fc = 66.5 Hz
> transition region = 0.5 Hz
> stopband atten = 40 dB
> ripple = 1 dB
>
> -Jeff
>
> > Problem whithin problem, if one of these cycles has greater magnitude
> > compared to the others, this greater magnitude acts like an
> electro-magnetic
> > fields and it distorts phase, amplitude and periods of its neighbors.
> >
> > To get as more as possible accurate spectrum, I would like to try to
> remove
> > each cycle found,one by one, and each time perform the fourier
> > transform since I do not know what other cycles could be hidden: if I
> could
> > be able to remove exacly the lower one, I could find next close one not
> seen
> > previously due to cluster or higher magnitude.
> >
> > Any suggestion on how to perform this? Or, do you think there are other
> ways
> > to do this?
> >
> > Regards,
> >
> > Alberto
> >
> >
> > 2009/8/17 Jeff Brower
> >
> >> Alberto-
> >>
> >> > having the spectrum of 5 cosine functions I need to remove the
> >> > lower one, does anybody knows how to do this?
> >> >
> >> > I have tried with moving average and this works correctly in
> >> > removing task, but I get alterated amplitudes and phases
> >> > in 4 remaining periods.
> >> >
> >> > What should I use to get removed lower one without problems?
> >>
> >> You might try a highpass filter, either IIR or FIR. Try adjusting the
>
> >> cutoff frequency to be about halfway between
> >> your lowest and next lowest frequencies.
> >>
> >> A running average (or averaging of any type) has more of a lowpass
> effect.
> >>
> >> -Jeff
> >>
> >> > Here is the code to create 5 cosine functions, I whis to remove
> Tf.38
> >> from serie12345
> >> >
> >> > Asim=[17, 18, 18.5, 19, 20]; %Amplitudes
> >> > Tsim=[22.5, 33, 44.28, 55.27, 66.38]; %Periods
> >> > fase=[1.1, 2.2, 3.3, 0.8, 2.7]; %Phases in radians
> >> > p=1:2048;
> >> > value=0;
> >> > Coseno1=0;
> >> > Coseno2=0;
> >> > Coseno3=0;
> >> > Coseno4=0;
> >> > Coseno5=0;
> >> >
> >> > Coseno1=Coseno1+Asim(1)*cos(2*pi*1/Tsim(1)*p+fase(1))';
> >> > Coseno2=Coseno2+Asim(2)*cos(2*pi*1/Tsim(2)*p+fase(2))';
> >> > Coseno3=Coseno3+Asim(3)*cos(2*pi*1/Tsim(3)*p+fase(3))';
> >> > Coseno4=Coseno4+Asim(4)*cos(2*pi*1/Tsim(4)*p+fase(4))';
> >> > Coseno5=Coseno5+Asim(5)*cos(2*pi*1/Tsim(5)*p+fase(5))';
> >> >
> >> > serie12345=Coseno1+Coseno2+Coseno3+Coseno4+Coseno5;
> >> >
> >> > %To remove with moving average:
> >> >
> >> > mm6638 = tsmovavg(serie12345, 's', 66.38, 1);
> >>
> >>
>