From: Ironic Prata on

I have a signal (decreasing exponential, added with a sinusoidal sign and some noise ).

I do Y = fft(d);

Correct me if i am wrong please:
The first value of Y is the sum of all components (dc component of signal?).
The rest of Y is symmetrical (even function) centered on sampling frequency.

Now i would like to simulate a high pass filter (to remove the exponential component). So i have to assign to 0, let´s say the first 10 elements in Y, as well as the last 10 elements right? And how about the fist value of Y? Make it 0 also or not?

signal=ifft(Y);

I´ve tried both cases, but the signal becomes imaginary, so i must be doing something wrong.
However, if i don´t alter Y, i can do a fft and ifft, and recover the sign, so i don't think the instructions are wrong.

I am looking more for a theoretical help, so i didn´t post the full code. If the theory in sound, and it still doesn´t work, i will post full code.

Thank You
From: Ironic Prata on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hpsjsn$imh$1(a)fred.mathworks.com>...
>
> You would set the first N elements to zero
>
> Y(1:10)=0; %N=10
>
> and the last N-1 to zero as well
>
> Y(end+1-9:end)=0; %N-1=9

Rune Allnor, i know i could do this with a filter, but in this case i prefer to learn this in a more theoretical point of view.

Matt J, you suggestion worked, but still left me with a problem: The reconstructed signal starts and ends at a value that seems to be respectively half of the original signal start and end, while in the middle it oscillates around zero(like i expect). That causes unwanted oscillations in the signal.
Should i just remove dc component of signal, or can this be addressed in the fft?

Thank You
From: Greg Heath on
On Apr 11, 9:37 am, "Ironic Prata" <lixodoiro...(a)hotmail.com> wrote:
> I have a signal (decreasing exponential, added with a sinusoidal sign and some noise ).
>
> I do Y = fft(d);
>
> Correct me if i am wrong please:
> The first value of Y is the sum of all components (dc component of signal?).

No.

DC(d) = Y(1)/N

where

N = length(d),


> The rest of Y is symmetrical (even function) centered on sampling frequency.

No.

Y is conjugate symmetric about the NYQUIST frequency fNy = Fs/2

df = Fs/N
f (n) = (n-1)*df; n=1:N

Y(N+2-k) = conj(Y(k)), k = 2:N

When N is even,

f(N/2+1) = df*N/2 = Fs/2 = fNy

whereas when N is odd,

f((N+1)/2) = df*(N-1)/2 = fNy - df/2
f((N+3)/2) = df*(N+1)/2 = fNy + df/2


> Now i would like to simulate a high pass filter (to remove the exponential component). So i have to assign to 0, let´s say the first 10 elements in Y, as well as the last 10
> elements right?

Wrong.

First you have to fftshift the spectrum

Yb = fftshift(Y);

to have the conjugate symmetry about fb = 0
within the bipolar frequency interval [ -fNy, fNy ).

fb = f-df*ceil((N-1)/2)
= df*[ -ceil((N-1)/2) : floor((N-1)/2)) ]

for N even

fb = df*[ -N/2 : N/2-1 ]
= [ - fNy : df : fNy - df ]

whereas for N odd (Note that (+/-)fNy are outside
of the interval)

fb = [ -fNy+df : df : fNy - df]

Now, to highpass filter, remove high frequency
components from both ends of the fftshifted spectrum
corresponding to the high frequency components in fb.

>And how about the fist value of Y? Make it 0 also or not?

No. DC is not a high frequency.

> signal=ifft(Y);

No.

Ybf = Yb(nlow:nhigh); % Highpass filtered

signal = ifft(ifftshift(Ybf));


Hope this helps.

Greg
From: Matt J on
"Ironic Prata" <lixodoironic(a)hotmail.com> wrote in message <hpt8gn$l8i$1(a)fred.mathworks.com>...

> Matt J, you suggestion worked, but still left me with a problem: The reconstructed signal starts and ends at a value that seems to be respectively half of the original signal start and end, while in the middle it oscillates around zero(like i expect). That causes unwanted oscillations in the signal.
> Should i just remove dc component of signal, or can this be addressed in the fft?
=========

By setting Y(1)=0 you've already removed the DC component. Since you said you were trying to recover a sinusoid, it's not at all clear what "unwanted oscillations" mean.

In any case, can't you look at the part of the signal where the exponentially decaying part has died down enough to have a negligible contribution? You should be able to get the frequency, phase, etc... of the sinusoid from that.
From: Greg Heath on
On Apr 11, 8:57 pm, Greg Heath <he...(a)alumni.brown.edu> wrote:
> On Apr 11, 9:37 am, "Ironic Prata" <lixodoiro...(a)hotmail.com> wrote:
>
> > I have a signal (decreasing exponential, added with a sinusoidal sign and some noise ).
>
> > I do Y = fft(d);
>
> > Correct me if i am wrong please:
> > The first value of Y is the sum of all components (dc component of signal?).
>
> No.
>
> DC(d) = Y(1)/N
>
> where
>
> N = length(d),
>
> > The rest of Y is symmetrical (even function) centered on sampling frequency.
>
> No.
>
> Y is conjugate symmetric about the NYQUIST frequency fNy = Fs/2
>
> df            = Fs/N
> f (n)        = (n-1)*df;   n=1:N
>
> Y(N+2-k) = conj(Y(k)),   k = 2:N
>
> When N is even,
>
> f(N/2+1) = df*N/2 = Fs/2 = fNy
>
> whereas when N is odd,
>
> f((N+1)/2) = df*(N-1)/2  = fNy - df/2
> f((N+3)/2) = df*(N+1)/2 = fNy + df/2
>
> > Now i would like to simulate a high pass filter (to remove the exponential component). So i have to assign to 0, let´s say the first 10 elements in Y, as well as the last 10
> > elements right?
>
> Wrong.
>
> First you have to fftshift the spectrum
>
> Yb = fftshift(Y);
>
> to have the conjugate symmetry about fb = 0
> within the bipolar frequency interval [ -fNy, fNy ).
>
> fb = f-df*ceil((N-1)/2)
>     = df*[ -ceil((N-1)/2) : floor((N-1)/2)) ]
>
> for N even
>
> fb = df*[ -N/2 : N/2-1 ]
>    = [ - fNy : df : fNy - df ]
>
> whereas for N odd (Note that (+/-)fNy are outside
> of the interval)
>
> fb   =  [ -fNy+df : df : fNy - df]
>
> Now, to highpass filter, remove high frequency
> components from both ends of the fftshifted spectrum
> corresponding to the high frequency components in fb.
>
> >And how about the fist value of Y? Make it 0 also or not?
>
> No. DC is not a high frequency.
>
> > signal=ifft(Y);
>
> No.
>
> Ybf = Yb(nlow:nhigh); % Highpass filtered
>
> signal = ifft(ifftshift(Ybf));

MEA CULPA!

What I have written is for LOW PASS!

Greg