Spectral Estimation Using Windows

Status
Not open for further replies.

Johnreilly70

Newbie level 1
Joined
Feb 16, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Hello All,

Im a trying to use windows to determine the frequencys and amplitudes of a random signal. The three windows I am using is Rectangular, Hamming & Blackman. I am needing help as I am able to plot graphs of the three windows with the signal convolved with it but i dont if what i am getting is correct. As the random signal i am given says at least one signal has a magnitude of 1000. Code is given below and signal is attached. Any help would be very much appreciated.

Thank you very much,
JohnReilly70

function [wr,whm,wb]=Johnwind_exp(sig,interp_factor,to_plot)

% This m-file generates three time windows of length 'wind_len'
% If plot_len = 0 then the program terminates
% If plot_len != 0 then the spectral plot of each window is drawn
% on a normalised frequency axis
% A total of 'freq_len' points are computed for the interpolated frequency response

close all
len=length(sig);
freq_len=len*interp_factor
freq2=1+freq_len/2

% generate 3 windows of length 256

wr=ones(1,len)'; % rectangular

whm=hamming(len); % hamming

wb=blackman(len); % Blackman

% generate the interpolated spectrum of each window

wrft=fft(wr,freq_len);
whmft=fft(whm,freq_len);
wbft=fft(wb,freq_len);


if to_plot == 0
return
else

sigfft=(fft(sig,freq_len)); % fft of signal
convRect=(wrft.*sigfft); %Convolving signal with Rectangular window
convHam=(sigfft.*whmft); %Convolving signal with Hamming window
convBlack=(sigfft.*wbft); %Convolving signal with Blackman window


hold
faxis=[0:1:freq2-1];
faxis=faxis'/freq_len;

subplot(3,1,1)
plot(faxis,20*log10(abs(convRect(1:freq2))/max(abs(convRect(1:freq2)))));
grid
subplot(3,1,2)
plot(faxis,20*log10(abs(convHam(1:freq2))/max(abs(convHam(1:freq2)))),'r');
grid
subplot(3,1,3)
plot(faxis,20*log10(abs(convBlack(1:freq2))/max(abs(convBlack(1:freq2)))),'k');
grid

xlabel('Frequency');
ylabel('Magnitude in dBs');
title(' Spectrum of windows:- Blue: Rectangular Red: Hamming Black: Blackman')

input('press any key to end')

hold
end
 

Attachments

  • Random Signal.txt
    18.5 KB · Views: 38

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…