PDA

View Full Version : the spectrum of symmetric vector


HyeeWang
03-04-2009, 02:36 AM
Help. Where it go wrong?

Get A N length even symmetric vector ,Fourier transform it and result
a spectrum vector with the same length
N,which the imaginary part must be zero.
In contrast to that, A N length odd symmetric vector should result
that the real part of spectrum is zero.


But I test and perform it and attain a wrong result. Where it go
wrong?

Here is matlab script to illustrate it.

N = 64;
x = randn(N,1);
y = [x;flipud(x)];
z = [x;-flipud(x)];

Y =fft(y);
Z =fft(z);
[Y,Z]

Cheers
[email protected]

Rune Allnor
03-04-2009, 08:57 AM
On 4 Mar, 03:36, HyeeWang <[email protected]> wrote:
> Help. Where it go wrong?
>
> Get A N length even symmetric vector ,Fourier transform it and result
> a spectrum vector with the same length
> N,which the imaginary part must be zero.
> In contrast to that, A N length odd symmetric vector should result
> that the real part of spectrum is zero.
>
> But I test and perform it and attain a wrong result. Where it go
> wrong?
>
> Here is matlab script to illustrate it.
>
> N = 64;
> x = randn(N,1);
> y = [x;flipud(x)];
> z = [x;-flipud(x)];

Two problems:

1) Your data are of even length, and thus not symmetric.
For the symmetry argument to work, the data needs to
have the property

x[-n] = x[n]

which leaves x[0] as a special case that appears once.

2) Your data are (almost) symmetric around N/2, not 0.
This would cause a linear phase shift of the spectrum
coefficinets.

So to get this to work, try again with a symmetric odd-length
sequence and account for the N/2 lag in the spectrum.

Rune

Andor
03-04-2009, 02:36 PM
On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
> Help. Where it go wrong?
>
> Get A N length even symmetric vector ,Fourier transform it and result
> a spectrum vector with the same length
> N,which the imaginary part must be zero.
> In contrast to that, A N length odd symmetric vector should result
> that the real part of spectrum is zero.
>
> But I test and perform it and attain a wrong result. Where it go
> wrong?
>
> Here is matlab script to illustrate it.
>
> N = 64;
> x = randn(N,1);
> y = [x;flipud(x)];
> z = [x;-flipud(x)];

You are making a very common mistake. Even and DFT-even is not the
same thing. If you want a DFT-even sequnce of length 128 you have 65
values that you can specify, the other 63 follow by symmetry. Check
out this thread:

http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c6fd21/a5592e52bcf5a134?hl=de&#a5592e52bcf5a134

Also, if you want a DFT-odd vector, remember that the middle value
(Nyquist value, only if you have length(z) even) has to be zero.

Regards,
Andor

HyeeWang
03-05-2009, 06:23 AM
On Mar 4, 4:57*pm, Rune Allnor <[email protected]> wrote:
> On 4 Mar, 03:36, HyeeWang <[email protected]> wrote:
>
>
>
>
>
> > Help. Where it go wrong?
>
> > Get A N length even symmetric vector ,Fourier transform it and result
> > a spectrum vector with the same length
> > N,which the imaginary part must be zero.
> > In contrast to that, A N length odd symmetric vector should result
> > that the real part of spectrum is zero.
>
> > But I test and perform it and attain a wrong result. Where it go
> > wrong?
>
> > Here is matlab script to illustrate it.
>
> > N = 64;
> > x = randn(N,1);
> > y = [x;flipud(x)];
> > z = [x;-flipud(x)];
>
> Two problems:
>
> 1) Your data are of even length, and thus not symmetric.
> * *For the symmetry argument to work, the data needs to
> * *have the property
>
> * *x[-n] = x[n]
>
> * *which leaves x[0] as a special case that appears once.
>
> 2) Your data are (almost) symmetric around N/2, not 0.
> * *This would cause a linear phase shift of the spectrum
> * *coefficinets.
>
> So to get this to work, try again with a symmetric odd-length
> sequence and account for the N/2 lag in the spectrum.
>
> Rune- Hide quoted text -
>
> - Show quoted text -

Thank you very much. Great Rune.Thank you for your instant and
elaborate comments. Hit the problem clearly.

I followed u and revised my matlab script and it worked well.

m = 8;
x = randn(m,1);
y = flipud(x);
z = [y(1:end-1);x];
N = 2*m - 1;
Z = fft(z);
k = [0:N-1]';
w = exp(-2j*pi*k*(N-1)/(2*N));
w2 = exp(2j*pi*k*(N+1)/(2*N));

Z = Z./w;
[Z]

But I have some tiny modification for your comments on the 1st
problem.

I still use even length vector and it work well also. I use the half
point concept about symmetry.

m = 8;
x = randn(m,1);
y = flipud(x);
z = [y(1:end);x];

N = 2*m ;
Z = fft(z);
k = [0:N-1]';
w = exp(-2j*pi*k*(N-1)/(2*N));
w2 = exp(2j*pi*k*(N+1)/(2*N));
Z = Z./w;
[Z]

HyeeWang
03-05-2009, 06:25 AM
On Mar 4, 10:36*pm, Andor <[email protected]> wrote:
> On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
>
>
>
>
>
> > Help. Where it go wrong?
>
> > Get A N length even symmetric vector ,Fourier transform it and result
> > a spectrum vector with the same length
> > N,which the imaginary part must be zero.
> > In contrast to that, A N length odd symmetric vector should result
> > that the real part of spectrum is zero.
>
> > But I test and perform it and attain a wrong result. Where it go
> > wrong?
>
> > Here is matlab script to illustrate it.
>
> > N = 64;
> > x = randn(N,1);
> > y = [x;flipud(x)];
> > z = [x;-flipud(x)];
>
> You are making a very common mistake. Even and DFT-even is not the
> same thing. If you want a DFT-even sequnce of length 128 you have 65
> values that you can specify, the other 63 follow by symmetry. Check
> out this thread:
>
> http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c...
>
> Also, if you want a DFT-odd vector, remember that the middle value
> (Nyquist value, only if you have length(z) even) has to be zero.
>
> Regards,
> Andor- Hide quoted text -
>
> - Show quoted text -


Thank you.Andor

I refered the link and got a lot.

Maybe I did not catch your comments fully. But I do not agree with
you.

1. Here, we talk symmetry in time domain,not in frequecny domain. So
it is none of the businesss with DFT-even.
2. About DFT-odd vector,maybe you are talking a DFT spectrum with odd
length. But in that case,there is not any ponit
to be the symmetrical center.
Let us take a example of 255 points spectrum.
Then the zeroth component is the DC, the 1--- 127th components is
conjugate symmetrical with 254 - 128th components.

Cheers
[email protected]

Andor
03-05-2009, 09:53 AM
On 5 Mrz., 07:25, HyeeWang <[email protected]> wrote:
> On Mar 4, 10:36*pm, Andor <[email protected]> wrote:
>
>
>
>
>
> > On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
>
> > > Help. Where it go wrong?
>
> > > Get A N length even symmetric vector ,Fourier transform it and result
> > > a spectrum vector with the same length
> > > N,which the imaginary part must be zero.
> > > In contrast to that, A N length odd symmetric vector should result
> > > that the real part of spectrum is zero.
>
> > > But I test and perform it and attain a wrong result. Where it go
> > > wrong?
>
> > > Here is matlab script to illustrate it.
>
> > > N = 64;
> > > x = randn(N,1);
> > > y = [x;flipud(x)];
> > > z = [x;-flipud(x)];
>
> > You are making a very common mistake. Even and DFT-even is not the
> > same thing. If you want a DFT-even sequnce of length 128 you have 65
> > values that you can specify, the other 63 follow by symmetry. Check
> > out this thread:
>
> >http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c...
>
> > Also, if you want a DFT-odd vector, remember that the middle value
> > (Nyquist value, only if you have length(z) even) has to be zero.
>
> > Regards,
> > Andor- Hide quoted text -
>
> > - Show quoted text -
>
> Thank you.Andor
>
> I refered the link and got a lot.
>
> Maybe I did not catch your comments fully. But I do not agree with
> you.
>
> 1. Here, we talk symmetry in time domain,not in frequecny domain. So
> it is none of the businesss with DFT-even.

The domain doesn't matter if you talk about symmetry for the DFT.
Consider your example:

N = 64;
x = randn(N,1);
y = [x;flipud(x)];
z = [x;-flipud(x)];


Y =fft(y);
Z =fft(z);
[Y,Z]

When you look at Y or Z, they are not purely real and imaginary as you
expect. The reason is that you are not using DFT symmetry. A real, DFT-
even vector has a real DFT-even spectrum. Your Y isn't real. Try this:

N = 64;
x1 = randn(N+1,1);
x2 = flipud(x1(2:end-1));
x = [x1;x2]
X =fft(x)


Notice that for a vector of length 128 you may specify 65 values (x1)
and the other 63 values (x2) follow from the necessary symmetry. X
has the same symmetry like x.

Regards,
Andor

HyeeWang
03-06-2009, 02:22 PM
On 3月5日, 下午5时53分, Andor <[email protected]> wrote:
> On 5 Mrz., 07:25, HyeeWang <[email protected]> wrote:
>
>
>
>
>
> > On Mar 4, 10:36 pm, Andor <[email protected]> wrote:
>
> > > On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
>
> > > > Help. Where it go wrong?
>
> > > > Get A N length even symmetric vector ,Fourier transform it and result
> > > > a spectrum vector with the same length
> > > > N,which the imaginary part must be zero.
> > > > In contrast to that, A N length odd symmetric vector should result
> > > > that the real part of spectrum is zero.
>
> > > > But I test and perform it and attain a wrong result. Where it go
> > > > wrong?
>
> > > > Here is matlab script to illustrate it.
>
> > > > N = 64;
> > > > x = randn(N,1);
> > > > y = [x;flipud(x)];
> > > > z = [x;-flipud(x)];
>
> > > You are making a very common mistake. Even and DFT-even is not the
> > > same thing. If you want a DFT-even sequnce of length 128 you have 65
> > > values that you can specify, the other 63 follow by symmetry. Check
> > > out this thread:
>
> > >http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c....
>
> > > Also, if you want a DFT-odd vector, remember that the middle value
> > > (Nyquist value, only if you have length(z) even) has to be zero.
>
> > > Regards,
> > > Andor- Hide quoted text -
>
> > > - Show quoted text -
>
> > Thank you.Andor
>
> > I refered the link and got a lot.
>
> > Maybe I did not catch your comments fully. But I do not agree with
> > you.
>
> > 1. Here, we talk symmetry in time domain,not in frequecny domain. So
> > it is none of the businesss with DFT-even.
>
> The domain doesn't matter if you talk about symmetry for the DFT.
> Consider your example:
>
> N = 64;
> x = randn(N,1);
> y = [x;flipud(x)];
> z = [x;-flipud(x)];
>
> Y =fft(y);
> Z =fft(z);
> [Y,Z]
>
> When you look at Y or Z, they are not purely real and imaginary as you
> expect. The reason is that you are not using DFT symmetry. A real, DFT-
> even vector has a real DFT-even spectrum. Your Y isn't real. Try this:
>
> N = 64;
> x1 = randn(N+1,1);
> x2 = flipud(x1(2:end-1));
> x = [x1;x2]
> X =fft(x)
>
> Notice that for a vector of length 128 you may specify 65 values (x1)
> and the other 63 values (x2) follow from the necessary symmetry. X
> has the same symmetry like x.
>
> Regards,
> Andor- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Andor. Thank you.

The topic is about that even symmetrical sequence produce real
spectrum.
What you talk is about that DFT-even symmetrical sequence prodeuce
real spectrum.
Both above are correct.

Although what you said do not correspond with the topic,you also get
the
equivalent result.

Thank you.
You teached me new knowledage.

By the way,What is exact definition of "DFT-even" and "DFT-odd"? And
what is their property ?

The example which you taked is a real DFT-even spectrum result. In
what case,can get a just imaginary spectrum?

Cheers
[email protected]

Andor
03-06-2009, 04:16 PM
On 6 Mrz., 15:22, HyeeWang <[email protected]> wrote:
> On 3月5日, 下午5时53分, Andor <[email protected]> wrote:
>
>
>
>
>
> > On 5 Mrz., 07:25, HyeeWang <[email protected]> wrote:
>
> > > On Mar 4, 10:36 pm, Andor <[email protected]> wrote:
>
> > > > On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
>
> > > > > Help. Where it go wrong?
>
> > > > > Get A N length even symmetric vector ,Fourier transform it and result
> > > > > a spectrum vector with the same length
> > > > > N,which the imaginary part must be zero.
> > > > > In contrast to that, A N length odd symmetric vector should result
> > > > > that the real part of spectrum is zero.
>
> > > > > But I test and perform it and attain a wrong result. Where it go
> > > > > wrong?
>
> > > > > Here is matlab script to illustrate it.
>
> > > > > N = 64;
> > > > > x = randn(N,1);
> > > > > y = [x;flipud(x)];
> > > > > z = [x;-flipud(x)];
>
> > > > You are making a very common mistake. Even and DFT-even is not the
> > > > same thing. If you want a DFT-even sequnce of length 128 you have 65
> > > > values that you can specify, the other 63 follow by symmetry. Check
> > > > out this thread:
>
> > > >http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c...
>
> > > > Also, if you want a DFT-odd vector, remember that the middle value
> > > > (Nyquist value, only if you have length(z) even) has to be zero.
>
> > > > Regards,
> > > > Andor- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Thank you.Andor
>
> > > I refered the link and got a lot.
>
> > > Maybe I did not catch your comments fully. But I do not agree with
> > > you.
>
> > > 1. Here, we talk symmetry in time domain,not in frequecny domain. So
> > > it is none of the businesss with DFT-even.
>
> > The domain doesn't matter if you talk about symmetry for the DFT.
> > Consider your example:
>
> > N = 64;
> > x = randn(N,1);
> > y = [x;flipud(x)];
> > z = [x;-flipud(x)];
>
> > Y =fft(y);
> > Z =fft(z);
> > [Y,Z]
>
> > When you look at Y or Z, they are not purely real and imaginary as you
> > expect. The reason is that you are not using DFT symmetry. A real, DFT-
> > even vector has a real DFT-even spectrum. Your Y isn't real. Try this:
>
> > N = 64;
> > x1 = randn(N+1,1);
> > x2 = flipud(x1(2:end-1));
> > x = [x1;x2]
> > X =fft(x)
>
> > Notice that for a vector of length 128 you may specify 65 values (x1)
> > and the other 63 values (x2) follow from the necessary symmetry. X
> > has the same symmetry like x.
>
> > Regards,
> > Andor- 隐藏被引用文字 -
>
> > - 显示引用的文字 -
>
> Andor. Thank you.
>
> The topic is about that even symmetrical sequence produce real
> spectrum.
> What you talk is about that DFT-even symmetrical sequence prodeuce
> real spectrum.
>
> Both above are correct.
>
> Although what you said do not correspond with the topic,you also get
> the equivalent result.

Excuse me?

You start off this thread by (correclty) noting that an even vector
does not have a real spectrum, and you ask why that is so. I reply by
saying that only DFT-even vectors have a real spectrum. Then you say
that wasn't the question, but you agree that a DFT-even vector has a
real spectrum and suddenly claim that even vectors also have real
spectrum (which, just two days ago, you noted not to be the case).
Finally, you say that these two claims are equivalent, although they
obviously are not.

Doesn't this strike you as a little bit odd, too? (pun intended :-).

Regards,
Andor

HyeeWang
03-07-2009, 05:28 AM
On 3月7日, 上午12时16分, Andor <[email protected]> wrote:
> On 6 Mrz., 15:22, HyeeWang <[email protected]> wrote:
>
>
>
>
>
> > On 3月5日, 下午5时53分, Andor <[email protected]> wrote:
>
> > > On 5 Mrz., 07:25, HyeeWang <[email protected]> wrote:
>
> > > > On Mar 4, 10:36 pm, Andor <[email protected]> wrote:
>
> > > > > On 4 Mrz., 03:36, HyeeWang <[email protected]> wrote:
>
> > > > > > Help. Where it go wrong?
>
> > > > > > Get A N length even symmetric vector ,Fourier transform it and result
> > > > > > a spectrum vector with the same length
> > > > > > N,which the imaginary part must be zero.
> > > > > > In contrast to that, A N length odd symmetric vector should result
> > > > > > that the real part of spectrum is zero.
>
> > > > > > But I test and perform it and attain a wrong result. Where it go
> > > > > > wrong?
>
> > > > > > Here is matlab script to illustrate it.
>
> > > > > > N = 64;
> > > > > > x = randn(N,1);
> > > > > > y = [x;flipud(x)];
> > > > > > z = [x;-flipud(x)];
>
> > > > > You are making a very common mistake. Even and DFT-even is not the
> > > > > same thing. If you want a DFT-even sequnce of length 128 you have65
> > > > > values that you can specify, the other 63 follow by symmetry. Check
> > > > > out this thread:
>
> > > > >http://groups.google.com/group/comp.dsp/browse_frm/thread/8fa3856859c...
>
> > > > > Also, if you want a DFT-odd vector, remember that the middle value
> > > > > (Nyquist value, only if you have length(z) even) has to be zero.
>
> > > > > Regards,
> > > > > Andor- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > Thank you.Andor
>
> > > > I refered the link and got a lot.
>
> > > > Maybe I did not catch your comments fully. But I do not agree with
> > > > you.
>
> > > > 1. Here, we talk symmetry in time domain,not in frequecny domain. So
> > > > it is none of the businesss with DFT-even.
>
> > > The domain doesn't matter if you talk about symmetry for the DFT.
> > > Consider your example:
>
> > > N = 64;
> > > x = randn(N,1);
> > > y = [x;flipud(x)];
> > > z = [x;-flipud(x)];
>
> > > Y =fft(y);
> > > Z =fft(z);
> > > [Y,Z]
>
> > > When you look at Y or Z, they are not purely real and imaginary as you
> > > expect. The reason is that you are not using DFT symmetry. A real, DFT-
> > > even vector has a real DFT-even spectrum. Your Y isn't real. Try this:
>
> > > N = 64;
> > > x1 = randn(N+1,1);
> > > x2 = flipud(x1(2:end-1));
> > > x = [x1;x2]
> > > X =fft(x)
>
> > > Notice that for a vector of length 128 you may specify 65 values (x1)
> > > and the other 63 values (x2) follow from the necessary symmetry. X
> > > has the same symmetry like x.
>
> > > Regards,
> > > Andor- 隐藏被引用文字 -
>
> > > - 显示引用的文字 -
>
> > Andor. Thank you.
>
> > The topic is about that even symmetrical sequence produce real
> > spectrum.
> > What you talk is about that DFT-even symmetrical sequence prodeuce
> > real spectrum.
>
> > Both above are correct.
>
> > Although what you said do not correspond with the topic,you also get
> > the equivalent result.
>
> Excuse me?
>
> You start off this thread by (correclty) noting that an even vector
> does not have a real spectrum, and you ask why that is so. I reply by
> saying that only DFT-even vectors have a real spectrum. Then you say
> that wasn't the question, but you agree that a DFT-even vector has a
> real spectrum and suddenly claim that even vectors also have real
> spectrum (which, just two days ago, you noted not to be the case).
> Finally, you say that these two claims are equivalent, although they
> obviously are not.
>
> Doesn't this strike you as a little bit odd, too? (pun intended :-).
>
> Regards,
> Andor- 隐藏被引用文字 -
>
> - 显示引用的文字 -

hi,Andor,thank you.

From what you talked,at begining,you have mistaken me and mistaken
what the topic is.

--- but you agree that a DFT-even vector has a
real spectrum and suddenly claim that even vectors also have real
spectrum (which, just two days ago, you noted not to be the case).

I never deny "even vectors also have real spectrum ". It is a basic
property of DFT.
You can retrieve it from any DSP textbook.

I started this thread because I wanna confirm the property and seek
some help to account for my problem.

You can read it again for your convenience.


Thank Rune for giving me help in solving it...