Hi,
I need to do this: I want to draw Hamming window in time and
frequency domain. In time domain it is simple, I just write
hamming(256) and plot. But I can't find function to view the
same in frequency domain. You can see what I want at: http://www.fit.vutbr.cz/~cernocky/speech/opora/zre_opora.pdf
page 38, chapter 5.3.2, pictures on the right.
Thanks for help.
On May 10, 3:58=A0pm, "Chen Sagiv" <chensagiv...@gmail.com> wrote:
> Hi,
>
> It is not important when you plot the abs of the FT, but
> shouldn't you use instead:
>
> > f1 =3D zeros(1,512);
> > f1(128:383) =3D hamming(256);
>
> > f2 =3D zeros(1,512);
> > f2(128:383) =3D 1;
>
> > fft_f1 =3D fftshift(fft(ifftshift(f1),2048));
> > fft_f2 =3D fftshift(fft(ifftshift(f2),2048));
Greg Heath <heath@alumni.brown.edu> wrote in message
<97e5fc3c-ddbc-4c0c-abd9-
c52e9a3ea38c@s50g2000hsb.googlegroups.com>...
> Corrected for the unforgivable sin of TOP-POSTING!
>
> On May 11, 7:00=A0am, "Chen Sagiv"
<chensagiv...@gmail.com> wrote:
> > Greg Heath <he...@alumni.brown.edu> wrote in message
> >
> > <3c59d7c3-618b-44c2-816a-
> > b58be9319...@24g2000hsh.googlegroups.com>...
> >
> > > On May 10, 3:58=3DA0pm, "Chen Sagiv"
> > <chensagiv...@gmail.com> wrote:
> > > > Hi,
> >
> > > > It is not important when you plot the abs of the
FT, but
> > > > shouldn't you use instead:
> >
> > > > > f1 =3D3D zeros(1,512);
> > > > > f1(128:383) =3D3D hamming(256);
> >
> > > > > f2 =3D3D zeros(1,512);
> > > > > f2(128:383) =3D3D 1;
> >
> > > > > fft_f1 =3D3D fftshift(fft(ifftshift(f1),2048));
> > > > > fft_f2 =3D3D fftshift(fft(ifftshift(f2),2048));
> >
> > > Absolutely not!
> >
> > > Hope this helps.
>
> > Hi Greg,
> >
> > No, it doesn't help. Can you explain your very short
> > response ?
>
> There is no point to using ifftshift.
>
> When I ran your code the spectra exhibted hashy
> artifacts.
>
> Did you cut what you wrote, paste it into a command
> line, and compare the plots with the originals??
>
> The results are obviously incorrect.
>
> Hope this helps.
>
> Greg
Greg Heath <heath@alumni.brown.edu> wrote in message
<97e5fc3c-ddbc-4c0c-abd9-
c52e9a3ea38c@s50g2000hsb.googlegroups.com>...
> Corrected for the unforgivable sin of TOP-POSTING!
>
> On May 11, 7:00=A0am, "Chen Sagiv"
<chensagiv...@gmail.com> wrote:
> > Greg Heath <he...@alumni.brown.edu> wrote in message
> >
> > <3c59d7c3-618b-44c2-816a-
> > b58be9319...@24g2000hsh.googlegroups.com>...
> >
> > > On May 10, 3:58=3DA0pm, "Chen Sagiv"
> > <chensagiv...@gmail.com> wrote:
> > > > Hi,
> >
> > > > It is not important when you plot the abs of the
FT, but
> > > > shouldn't you use instead:
> >
> > > > > f1 =3D3D zeros(1,512);
> > > > > f1(128:383) =3D3D hamming(256);
> >
> > > > > f2 =3D3D zeros(1,512);
> > > > > f2(128:383) =3D3D 1;
> >
> > > > > fft_f1 =3D3D fftshift(fft(ifftshift(f1),2048));
> > > > > fft_f2 =3D3D fftshift(fft(ifftshift(f2),2048));
> >
> > > Absolutely not!
> >
> > > Hope this helps.
>
> > Hi Greg,
> >
> > No, it doesn't help. Can you explain your very short
> > response ?
>
> There is no point to using ifftshift.
>
> When I ran your code the spectra exhibted hashy
> artifacts.
>
> Did you cut what you wrote, paste it into a command
> line, and compare the plots with the originals??
>
> The results are obviously incorrect.
>
> Hope this helps.
>
> Greg
Hi again,
As a new member to the newsgroup, I just realized what you
meant by top-posting. I do hope this will be the worst sin
in my life, but I will try to avoid it from now on.
On May 11, 9:26=A0am, "Chen Sagiv" <chensagiv...@gmail.com> wrote:
> Greg Heath <he...@alumni.brown.edu> wrote in message
>
> <97e5fc3c-ddbc-4c0c-abd9-
> c52e9a3ea...@s50g2000hsb.googlegroups.com>...
>
> > Corrected for the unforgivable sin of TOP-POSTING!
>
> > On May 11, 7:00=3DA0am, "Chen Sagiv"
> <chensagiv...@gmail.com> wrote:
> > > Greg Heath <he...@alumni.brown.edu> wrote in message
>
> > > <3c59d7c3-618b-44c2-816a-
> > > b58be9319...@24g2000hsh.googlegroups.com>...
>
> > > > On May 10, 3:58=3D3DA0pm, "Chen Sagiv"
> > > <chensagiv...@gmail.com> wrote:
> > > > > Hi,
>
> > > > > It is not important when you plot the abs of the
> FT, but
> > > > > shouldn't you use instead:
>
> > > > > > f1 =3D3D3D zeros(1,512);
> > > > > > f1(128:383) =3D3D3D hamming(256);
>
> > > > > > f2 =3D3D3D zeros(1,512);
> > > > > > f2(128:383) =3D3D3D 1;
>
> > > > > > fft_f1 =3D3D3D fftshift(fft(ifftshift(f1),2048));
> > > > > > fft_f2 =3D3D3D fftshift(fft(ifftshift(f2),2048));
>
> > > > Absolutely not!
>
> > > > Hope this helps.
>
> > > Hi Greg,
>
> > > No, it doesn't help. Can you explain your very short
> > > response ?
>
> > There is no point to using ifftshift.
>
> > When I ran your code the spectra exhibted hashy
> > artifacts.
>
> > Did you cut what you wrote, =A0paste it into a command
> > =A0line, and compare the plots with the originals??
>
> > The results are obviously incorrect.
Greg Heath <heath@alumni.brown.edu> wrote in message
<0d25ec05-ce98-47fa-868e-
d33bb49dfec8@f36g2000hsa.googlegroups.com>...
> On May 11, 9:26=A0am, "Chen Sagiv"
<chensagiv...@gmail.com> wrote:
> > Greg Heath <he...@alumni.brown.edu> wrote in message
> >
> > <97e5fc3c-ddbc-4c0c-abd9-
> > c52e9a3ea...@s50g2000hsb.googlegroups.com>...
> >
> > > Corrected for the unforgivable sin of TOP-POSTING!
> >
> > > On May 11, 7:00=3DA0am, "Chen Sagiv"
> > <chensagiv...@gmail.com> wrote:
> > > > Greg Heath <he...@alumni.brown.edu> wrote in message
> >
> > > > <3c59d7c3-618b-44c2-816a-
> > > > b58be9319...@24g2000hsh.googlegroups.com>...
> >
> > > > > On May 10, 3:58=3D3DA0pm, "Chen Sagiv"
> > > > <chensagiv...@gmail.com> wrote:
> > > > > > Hi,
> >
> > > > > > It is not important when you plot the abs of the
> > FT, but
> > > > > > shouldn't you use instead:
> >
> > > > > > > f1 =3D3D3D zeros(1,512);
> > > > > > > f1(128:383) =3D3D3D hamming(256);
> >
> > > > > > > f2 =3D3D3D zeros(1,512);
> > > > > > > f2(128:383) =3D3D3D 1;
> >
> > > > > > > fft_f1 =3D3D3D fftshift(fft(ifftshift
(f1),2048));
> > > > > > > fft_f2 =3D3D3D fftshift(fft(ifftshift
(f2),2048));
> >
> > > > > Absolutely not!
> >
> > > > > Hope this helps.
> >
> > > > Hi Greg,
> >
> > > > No, it doesn't help. Can you explain your very short
> > > > response ?
> >
> > > There is no point to using ifftshift.
> >
> > > When I ran your code the spectra exhibted hashy
> > > artifacts.
> >
> > > Did you cut what you wrote, =A0paste it into a command
> > > =A0line, and compare the plots with the originals??
> >
> > > The results are obviously incorrect.
>
> > Dear Greg,
> >
> > I refer you to a previous discussion at:
> >
> > http://www.mathworks.com/matlabcentral/newsreader/view_threa
> > d/168642#430044
>
> Let me repeat
>
> When I ran your code the spectra exhibted hashy
> artifacts. Did you actually run it??
>
> I read the reference thread. What is your point?
>
> Greg
>
> P.S. You may want to take a look at
>
> fftshift([0 1 2 3 4 5 6 7])
> ifftshift([0 1 2 3 4 5 6 7])
> fftshift([0 1 2 3 4 5 6 7 8])
> ifftshift([0 1 2 3 4 5 6 7 8])
Hi Greg,
I ran the code, and indeed it looks nasty.
My point is however very simple.
If you take the code suggested in the beginning of this all
discussion and display the imaginary rather the abs value
you will get a phase, which you should be aware of if you
account for the real and imaginary values of the FT
separately. This is my point !
On May 12, 4:13 am, "Chen Sagiv" <chensagiv...@gmail.com> wrote:
> -----SNIP
> If you take the code suggested in the beginning of this all
> discussion and display the imaginary rather the abs value
> you will get a phase, which you should be aware of if you
> account for the real and imaginary values of the FT
> separately. This is my point !
There are two impotant points:
1. The difference between the fft of x1(t) and
x2(t) = x(t-t0) is a complex multiplier linear
phase shift exp(-2*pi*f*t0). Therefore, if
X1 = fft(x1) is real, X2 = fft(x2) will be
complex.
2. The fft of a zero padded version of x will also
be complex.
Greg Heath <heath@alumni.brown.edu> wrote in message
<08b54431-1628-4ae0-9506-
1ed9fe6469c3@f36g2000hsa.googlegroups.com>...
> On May 12, 4:13 am, "Chen Sagiv" <chensagiv...@gmail.com>
wrote:
> > -----SNIP
> > If you take the code suggested in the beginning of this
all
> > discussion and display the imaginary rather the abs
value
> > you will get a phase, which you should be aware of if
you
> > account for the real and imaginary values of the FT
> > separately. This is my point !
>
> There are two impotant points:
>
> 1. The difference between the fft of x1(t) and
> x2(t) = x(t-t0) is a complex multiplier linear
> phase shift exp(-2*pi*f*t0). Therefore, if
> X1 = fft(x1) is real, X2 = fft(x2) will be
> complex.
> 2. The fft of a zero padded version of x will also
> be complex.
>
> close all, clear all, clc, k=0
>
> x0 = ones(1,16);
> x1 = [ones(1,16) zeros(1,16)];
> x2 = [zeros(1,8) ones(1,16) zeros(1,8)];
> x3 = [zeros(1,16) ones(1,16)];
>
> k=k+1,figure(k)
>
> subplot(2,2,1); plot(x0); axis([-5 35 -0.1 1.1])
> subplot(2,2,2); plot(x1); axis([-5 35 -0.1 1.1])
> subplot(2,2,3); plot(x2); axis([-5 35 -0.1 1.1])
> subplot(2,2,4); plot(x3); axis([-5 35 -0.1 1.1])
>
> X0 = fftshift(fft(x0));
> X1 = fftshift(fft(x1));
> X2 = fftshift(fft(x2));
> X3 = fftshift(fft(x3));
>
> k=k+1,figure(k)
> subplot(2,2,1); plot(imag(X0)); axis([-5 35 -11 11])
> subplot(2,2,2); plot(imag(X1)); axis([-5 35 -11 11])
> subplot(2,2,3); plot(imag(X2)); axis([-5 35 -11 11])
> subplot(2,2,4); plot(imag(X3)); axis([-5 35 -11 11])
>
> Hope this helps,
>
> Greg
>
Hi Greg,
Thanks for the example.
Chen
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.