Hey
This is my modified code. My filtered signal looks like a V shape, where
the centre is sloped down. I don't think that looks right, why is that??
figure(1)
t = (0:2/(88200-1):2);
plot(t,y)
title('Brain Signal (2 sec)')
xlabel('Time(t)')
ylabel('Voltage(v)')
Y = y.*hamming(length(y));
figure(2)
plot(t,Y)
title('Hamming window applied to signal')
xlabel('Time(t)')
ylabel('Voltage(v)')
figure(3)
X = fft(Y);
plot(X)
title('FFTed signal')
xlabel('logf')
ylabel('log|Y|')
Z = X.*conj(X);
figure(4)
plot(Z)
title('Hamming window + Conjugate applied')
xlabel('logf')
ylabel('log|Y|')
figure(5)
loglog(Z)
title('loglog plot')
figure(6)
semilogx(Z)
title('semilogx plot')
figure(7)
semilogy(Z)
title('semilogy plot')
A = fftshift(Z);
figure(8)
semilogy(A)
title('Simplified signal in frequency domain')
figure(9)
f = (-fs/2:1/2:fs/2-1/2)/1000;
semilogy(f,A)
title('Simplified signal in frequency domain')
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 = 500/0.5;
P = 44100-S:44100+S;
V(1,P) = 1;
plot(f,V)
title('Filter')
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(t(P),abs(I))
title('Filtered signal in time domain')
xlabel('Time(t)')
Reply by Fred Marshall●March 27, 20062006-03-27
Search amazon.com for ["digital signal processing" matlab] and see the books
that pop out.
Ingle, Proakis
Mitra
Stearns
all seem to get high marks.
I wouldn't be surprised if you can't find some matlab code for dsp on the
web.
So, there would be examples.
matlab is a language so you need to learn the language separately I should
think - at least that would be my approach. Then you can use tricks learned
from real code.
A good book on matlab might be a good idea because the DSP books probably
won't help much in learning how to construct things.
But, hey, it's an iterative process and we've all used somebody else's code
to avoid learning a whole lot of new stuff at once haven't we?
Fred
Reply by Jerry Avins●March 27, 20062006-03-27
rajgerman wrote:
> Hey
>
> Thanks that explained alot. Could you recommend me a good book that deals
> with matlab and dsp together or any good dsp book that will help me??
I know very little about Matlab, but I do know that it has a good help
system. Matlab is a tool for exploring your designs and for solving
specific problems (like quickly computing window and filter
coefficients, and transforms). It's like a very sophisticated
bulldozer-backhoe combination. It's a lot faster than digging by hand,
but in needs a plan to be useful.
At your level, I can't think of any better book than Lyons:
"Understanding Digital Signal Processing". There's an on-line book
that's also good: "The Scientist and Engineer's Guide to Digital Signal
Processing" by Steven W. Smith; http://dspguide.com/. There is a book
that deals with doing DSP using Matlab. I don't know it.
Conscious ignorance rarely gets me into deep trouble. Being wrong about
what I think I know really hurts. I just bought a lens for $60 that I
only thought I could use.
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
Reply by rajgerman●March 27, 20062006-03-27
Hey
Thanks that explained alot. Could you recommend me a good book that deals
with matlab and dsp together or any good dsp book that will help me??
Thanks
Raj
Reply by Jerry Avins●March 27, 20062006-03-27
rajgerman wrote:
>>rajgerman wrote:
>>
>>>Hey
>>>
>>>Ok instead of X = Y.*hamming(length(Y)); it should be:
>>>
>>>W = hamming(length(Y));
>>>
>>>X = conv(Y,W);
>>>
>>>Or do I have to fft W as well and then convolve Y and W??
>>>
>>>Thanks Raj
>
>
> No Y is in the frequency domain. I'm a bit confused.
You start with a sequence of samples, equally spaced in time.
To see the spectrum of the signal that the samples represent, you
perform an FFT on those samples. Often the FFT will give a clearer
picture of the spectrum if you modify the samples with a tapered window
/before/ performing the FFT.
Now: you can either multiply the window vector by the sample vector and
FFT the product as I described -- that's the efficient way -- or FFT the
sample array, and convolve the result with the FFTed window, taking care
that the convolution isn't circular. The second way works in theory, but
there's no reason to use it.
Matlab is too automatic to be a good learning tool. It lets one easily
do complicated operations without having to understand what they are or
what they do. It lets one operate on vast amounts of data with no
understanding of what the data mean, either before or after the
operations. You will get more out of it after you have done a simple
problem by hand. That will make the nature and sequence of the
operations clear.
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
Reply by rajgerman●March 27, 20062006-03-27
Hey
Y = frequency domain (data)
W = which is the hamming window is in the time domain
Am I right with W??
How will this change my code?
Thanks Raj
Reply by rajgerman●March 27, 20062006-03-27
>rajgerman wrote:
>> Hey
>>
>> Ok instead of X = Y.*hamming(length(Y)); it should be:
>>
>> W = hamming(length(Y));
>>
>> X = conv(Y,W);
>>
>> Or do I have to fft W as well and then convolve Y and W??
>>
>> Thanks Raj
No Y is in the frequency domain. I'm a bit confused.
Reply by Jerry Avins●March 27, 20062006-03-27
rajgerman wrote:
> Hey
>
> Ok instead of X = Y.*hamming(length(Y)); it should be:
>
> W = hamming(length(Y));
>
> X = conv(Y,W);
>
> Or do I have to fft W as well and then convolve Y and W??
>
> Thanks Raj
We're at cross purposes. Assuming that X and Y are arrays of samples in
time, then X = Y.*hamming(length(Y)) is exactly what you want to do.
Then FFT X. Your use of capital X and Y lead me to wonder is they really
are time samples. If not, they should be.
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
Reply by rajgerman●March 27, 20062006-03-27
Hey
Ok instead of X = Y.*hamming(length(Y)); it should be:
W = hamming(length(Y));
X = conv(Y,W);
Or do I have to fft W as well and then convolve Y and W??
Thanks Raj
Reply by Jerry Avins●March 27, 20062006-03-27
rajgerman wrote:
> Hey
>
> Is it true that a Hamming window should be computed in the time domain and
> not in the frequency domain like I have done??
That's the way it's usually done. Applying it in the time domain uses
multiplication, but in the frequency domain you must convolve. (If you
multiply the time domain sequence by the frequency results, you get a
hump in the middle without the expected benefits anywhere.
Are you familiar with the silly joke about the man with "a knocking in
the head and a ringing in the ears"? (On request.)
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������