Pages

Friday, August 5, 2011

HOW TO SOLVE 12 BALLS PROBLEM? 12 BALLS 3 WEIGHING ONE BALANCE

Saturday, May 7, 2011

EFFECT OF RECTANGULAR | HAMMING | HANNING | BLACK MAN WINDOWS ON FIR lowpass filter

clear all;
close all;
f=input('enter the freq');
N=input('enter the number of samples');
w=2*pi*f;
alpha=(N-1)/2;
h=zeros(1,N);
for n=0:1:N-1
    if n~=(N-1)/2
    h(n+1)=sin(w*(n-alpha))/((n-alpha)*pi);
    h(n+1)=1-h(n+1);
    end
end
h(((N-1)/2)+1)=w/pi;
rectangular_window=boxcar(N);
ham=hamming(N);
han=hanning(N);
black=blackman(N);
h1=h.*rectangular_window';
h2=h.*ham';
h3=h.*han';
h4=h.*black';
w=0:.01:pi;
H1=freqz(h1,1,w);
H2=freqz(h2,1,w);
H3=freqz(h3,1,w);
H4=freqz(h4,1,w);
plot(w/pi,abs(H1),'r',w/pi,abs(H2),'g',w/pi,abs(H3),'y',w/pi,abs(H4));


OUTPUT
enter the freq 0.3*pi
enter the samples 33

PLOT

EFFECT OF WINDOWS ON FIR lowpass filter

Wednesday, April 27, 2011

DESIGN FIR LOWPASS FILTER WITH CUTOFF FREQUENCY 0.5*pi using HAMMING WINDOW

clear all;
wcutoff=input('ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->');
N=input('ENTER THE NUMBEROF SAMPLES eg: N=25--->');
alpha=(N-1)/2;
epso=.001;              %to prevent singularity when n=alphan=0:1:N-1;
hd=sin(wcutoff*(n-alpha+epso))./(pi*(n-alpha+epso));
%expression for FIR Lowpass filter


wr=hamming(N);      %expression for Hamming window
hn=hd.*wr';               %wr'=transpose of wrw=0:0.01:pi;
h=freqz(hn,1,w);       %MATLAB function for frequency response
xlabel('Normalised frequency \omega/\pi');
ylabel('Magnitude');
plot(w/pi,abs(h));     %to plot the graph


CLICK HERE FOR FIR LPF using RECTANGULAR WINDOW

OUTPUT
ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->0.5*pi
ENTER THE NUMBEROF SAMPLES eg: N=25--->31

PLOT

FIR LOWPASS FILTER USING HAMMING WINDOW

DESIGN FIR LOWPASS FILTER WITH CUTOFF FREQUENCY 0.5*pi using RECTANGULAR WINDOW

clear all;
wcutoff=input('ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->');
N=input('ENTER THE NUMBEROF SAMPLES eg: N=25--->');
alpha=(N-1)/2;
epso=.001;          %to prevent singularity when n=alphan=0:1:N-1;
hd=sin(wcutoff*(n-alpha+epso))./(pi*(n-alpha+epso));
                              %expression for FIR Lowpass filterwr=boxcar(N);       %expression for Rectangular window
hn=hd.*wr';            %wr'=transpose of wr
w=0:0.01:pi;
h=freqz(hn,1,w);    %MATLAB function for frequency response
xlabel('Normalised frequency \omega/\pi');
ylabel('Magnitude');
plot(w/pi,abs(h));  %to plot the graph


OUTPUT

ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->0.5*pi
ENTER THE NUMBER OF SAMPLES eg: N=25--->31

PLOT


FIR LOWPASS FILTER USING RECTANGULAR WINDOW

Sunday, March 6, 2011

MATLAB PROGRAM TO IMPLEMENT SAMPLING THEOREM for all Nyquist conditions


close all;
clear all;
t=-10:0.01:10;
T=8;
fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.2*fm;
fs2=2*fm;
fs3=8*fm;
n1=-4:1:4;
xn1=cos(2*pi*n1*fm/fs1);
subplot(221)
plot(t,x);
xlabel('time in seconds');
ylabel('x(t)');
title('continous time signal');
subplot(222)
stem(n1,xn1);
hold on;
plot(n1,xn1);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
%
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(223)
stem(n2,xn2);
hold on;
plot(n2,xn2);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
%
n3=-20:1:20;
xn3=cos(2*pi*n3*fm/fs3);
subplot(224)
stem(n3,xn3);
hold on;
plot(n3,xn3);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs>2fm');