DSPRelated.com
Forums

Hamming window

Started by rajgerman February 19, 2006
jim wrote:
> > Jerry Avins wrote: > >>rajgerman wrote: >> >>>Hey >>> >>>I think I have an idea. I will create a vector (V) of the same length as >>>my signal, which will mostly contain 0's and 1's. 0's will get rid of the >>>frequncies I don't want and so on... >>> >>>Does that sound ok?? >> >>No. It will do what you want at the bin centers, but in between the >>response will be horrible. > > > > Why will it be horrible? As far as I can tell The OP has never explained > what he wants to do this time domain signal once he gets it. Given that > you have no idea what purpose this signal might serve how can you make a > judgment that it will be horrible. Maybe he doesn't want the in between > frequencies. Or maybe he doesn't know what he wants.
Did you read the whole thread? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Hey

Once I have filtered out the frequencies I don't want plus ifft the
results then I will compare them to the data collected from the eye.

I'm trying to create a vector with zeros and ones but finding it
difficult. So far I have done the following:

V = ones(1,88200);
f = -44100/2:1/2:44100/2-1/2;

I have now described the x-axis of V in frequency terms. Now how do I
convert the 1's outside -5000Hz and 5000Hz from V into 0's?? 

So then I'm able to multiply the result to my ffted data as stated in the
previous posts. I know some of you suggest that this is not the best
method but I'm just trying out different ways. Please bear in mind I'm
just a beginner to DSP and MATLAB.

Thanks

Raj
"rajgerman" <rajgerman@msn.com> wrote in message 
news:d_ydnQlKQPSy8pXZRVn-iA@giganews.com...
> Hey > > Once I have filtered out the frequencies I don't want plus ifft the > results then I will compare them to the data collected from the eye. > > I'm trying to create a vector with zeros and ones but finding it > difficult. So far I have done the following: > > V = ones(1,88200); > f = -44100/2:1/2:44100/2-1/2; > > I have now described the x-axis of V in frequency terms. Now how do I > convert the 1's outside -5000Hz and 5000Hz from V into 0's?? > > So then I'm able to multiply the result to my ffted data as stated in the > previous posts. I know some of you suggest that this is not the best > method but I'm just trying out different ways. Please bear in mind I'm > just a beginner to DSP and MATLAB. > > Thanks > > Raj
Please forgive me if I sound harsh but I get the idea that you're being lazy in your approach to things. That won't serve you well. You might ask yourself: "what is my real objective here?" In business it's OK to just get the job done. In school it's necessary to get the job done but if that's all you do then the objective of "education" is blunted. You need to go read the matlab manual. Selective reading is fine. Just go find what you need and apply it. Eventually you will have the set of tricks you need in your head. what is V? A lesson in technology is that semantics, terminology, definitions, etc. are very important. Might I suggest you follow that principle and define your terms? It will help a lot! You would serve yourself well by getting off the kick of wanting to refer to the frequency data on an absolute frequency axis. All programming is done in terms of indices as in 0,1,2,3... in "C" or 1,2,3,4.... in matlab. You only need to know the relationship between indices and the underlying variable - but that's relatively easy because, after all, you set it up. Stay in index terms in the program. If you want pretty plots *only then* do you need to generate vectors for the x axis and maybe the y axis. Back to setting those zeros: What are the indices of the variable that you want to set to zero? How do you set a value in a vector to zero? Hint: x(5)=0; How do you set a contiguous range of vector values to zero or anything else? Do you know any computer languages like C? I can think of at least two approaches. One is an explicit loop. for i=7:99, etc. The other does the same thing but is done using indexing notation or shorthand - an implicit loop. Go read. If the problem is that you don't have a book then I'm sure folks will be more helpful. But sometimes what appears to be help is really not help at all. So I'm trying to give you real help. Fred

Jerry Avins wrote:

> > Did you read the whole thread?
No I didn't. I read all of Rajgermans posts. Did someone else explain what he wants to do? -jim ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
It's ok Fred I have got it figured out now.

Thanks for your help anyway.

rajgerman wrote:
> > Hey > > Once I have filtered out the frequencies I don't want plus ifft the > results then I will compare them to the data collected from the eye.
What does compare mean? Will the data from the eye undergo the same processing. Wouldn't a comparison in the frequency domain be more revealing? Why do you want to compare only a very small portion of the spectrum? -jim ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
rajgerman wrote:
> Hey > > Once I have filtered out the frequencies I don't want plus ifft the > results then I will compare them to the data collected from the eye. > > I'm trying to create a vector with zeros and ones but finding it > difficult. So far I have done the following: > > V = ones(1,88200); > f = -44100/2:1/2:44100/2-1/2; > > I have now described the x-axis of V in frequency terms. Now how do I > convert the 1's outside -5000Hz and 5000Hz from V into 0's?? > > So then I'm able to multiply the result to my ffted data as stated in the > previous posts. I know some of you suggest that this is not the best > method but I'm just trying out different ways. Please bear in mind I'm > just a beginner to DSP and MATLAB.
Oho! Before, you wrote 5 Hz. Now it appears that 5 Hz was a mistake, and it should have been 5 KHz. That changes many of the numbers in Fred's response to you. It see the frequency response of your brick-wall filter, you will need to start with a signal that has uniform response initially. A pseudorandom bit stream will serve. Be warned: the response above 5 KHz will be quite large at some frequencies. This will show best on a logarithmic (decibel) vertical scale. It might also be instructive to use a squarish pulse (corners softened to remove frequencies above 20 KHz) and observe the shape of the filtered result. You once wrote, "I'm not too good with matlab so I'm trying to find the most easiest way. I also don't want to use the signal processing tools." You can't learn to drive a car without learning also where the pedals are and what they do. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Yeah sorry my bad, it is 5KHz. 

It's ok guys I appreciate all your help but I think I have worked
something out.

Thanks again.
Hey guys I'm back.

As I have told you before I have a brain signal (wav file, 2 sec
duration). I applied ffted, hamming window, filter, etc. to the signal to
extract certain frequencies. I will provide the code I used below so that
you will have a better idea of what I have done. y is my original brain
signal. Please ignore the last two sections of the code. 

When I plot my new filtered signal depending on the frequencies I choose,
sometimes I get a bell shaped plot. I wanted to know what could cause this
e.g. could it be the hamming window applied earlier or anything else? Could
anyone tell me topics to read on about my problem? Thanks.

figure(1)
t = (0:2/(88200-1):2);         
plot(t,y)
title('Brain Signal')
xlabel('Time(t)')
ylabel('Voltage(v)')

figure(2)                      
Y = fft(y);
plot(Y)
title('FFT Brian Signal')
xlabel('logf')
ylabel('log|Y|')

%Hamming window%
 
X = Y.*hamming(length(Y));      
                                            
figure(3)
plot(X)                                       

Z = X.*conj(X);                

figure(4)
plot(Z)

figure(5)
loglog(Z)                      
figure(6)
semilogx(Z)                    

figure(7)
semilogy(Z)                    
A = fftshift(Z);

figure(8)
semilogy(A)          
                               


figure(9)
f = (-fs/2:1/2:fs/2-1/2)/1000;
semilogy(f,A)
xlabel('Frequency (KHz)')

figure(10)
f2 = (0+1/2:1/2:fs/2)/1000;               
A_p = A(end/2+1:end);
semilogy(f2,A_p)
title('positive side of A')
xlabel('Frequency (KHz)')

figure(11)
f3 = (-fs/2:1/2:0-1/2)/1000;               
A_n = A(1:end/2);
semilogy(f3,A_n)
title('Negative side of A')
xlabel('Frequency (KHz)')


figure(12)
V = zeros(1,88200);                         
f = (-44100/2:1/2:44100/2-1/2)/1000;
S = 5000/0.5;                               
P = 44100-S:44100+S;
V(1,P) = 1;
plot(f,V)
title('Filter for the range -5KHz:5KHz')
xlabel('Frequency (KHz)')

F_filt=A(P);                                
f_filt=f(P);

figure(13)                             
semilogy(f_filt,F_filt)
title('Filtered data')
xlabel('Frequency (KHz)')

%figure(14)
%I = ifft(fftshift(F_filt));            
%plot(abs(I))
%xlabel('Time(t)')


%X_filt = I.*hamming(length(I));         
%figure(15)
%plot(abs(X_filt))
%xlabel('Time(t)')

rajgerman wrote:
> Hey guys I'm back.
And a hearty welcome to ya! ...
> When I plot my new filtered signal depending on the frequencies I choose, > sometimes I get a bell shaped plot. I wanted to know what could cause this
Either that's the real shape of your data, or the computation is awry.
> e.g. could it be the hamming window applied earlier or anything else?
Symmetric windows don't do that.
> Could anyone tell me topics to read on about my problem? Thanks.
there are many good references in http://www.dspguru.com/. Check "Books", "Tutorial", and more. ... Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;