Date : 23-06-2010
1
y=sawtooth((2*pi*f*t),(width));
subplot(2,2,3);
plot(t,y);
title('triangular wave');
xlabel('time');
ylabel('amplitude');
RESULT
0.5 0.5
amplitude
amplitude
0 0
-0.5 -0.5
-1 -1
0 5 10 0 5 10
time time
triangular wave
1
0.5
amplitude
-0.5
-1
0 5 10
time
2
EXPERIMENT NO:2
Date : 30-06-2010
AM , FM AND PWM
% Amplitude modulation
clear all;clc;clf;
Ec=input('amplitude of carrier signal')'
Em=input('amplitude of modulating signal');
Fc=input('frequency of carrier signal');
Fm=input('frequency of modulating signal');
t=linspace(0,1,100);
ec=Ec*cos(Fc*t);
em=Em*cos(Fm*t);
e=(Ec+Em*cos(Fm*t)).*cos(Fc*t);
subplot(2,2,1);
plot(ec);
xlabel('time');
ylabel('amplitude');
title('carrier signal');
grid on
subplot(2,2,2);
plot(em);
xlabel('time');
ylabel('amplitude');
title('modulating signal');
grid on
subplot(2,2,3);
3
plot(e);
xlabel('time');
ylabel('amplitude');
title('modulated signal');
RESULT
0.5
amplitude
amplitude
0 0
-0.5
-5 -1
0 50 100 0 50 100
time time
modulated signal
10
5
amplitude
-5
-10
0 50 100
time
4
% Frequency Modulation
clear all;clc;clf;
Ec=input('amplitude of carrier signal=');
Em=input('amplitude of modulating signal=');
Fc=input('frequency of carrier signal=');
Fm=input('frequency of modulating signal=');
f=input('frequency deviation=');
t=linspace(0,1,100);
ec=Ec*cos(Fc*t);
em=Em*cos(Fm*t);
e=Ec*cos((Fc*t)+((f/Fm).*sin(Fm*t)));
subplot(2,2,1);
plot(ec);
xlabel('time');
ylabel('amplitude');
title('carrier signal');
grid on
subplot(2,2,2);
plot(em,'g');
xlabel('time');
ylabel('amplitude');
title('modulating signal');
grid on
subplot(2,2,3);
plot(e,'r');
xlabel('time');
ylabel('amplitude');
title('modulated signal');
5
RESULT
0.5
amplitude
amplitude
0 0
-0.5
-5 -1
0 50 100 0 50 100
time time
modulated signal
5
amplitude
-5
0 50 100
time
6
%Pulse width modulation
clc;
t=0:0.001:1;
s=sawtooth(2*pi*10*t+pi);
m=0.75*sin(2*pi*1*t);
n=length(s);
for i=1:n
if (m(i)>=s(i))
PWM(i)=1;
elseif (m(i)<=s(i))
PWM(i)=0;
end
end
plot(t,PWM,'b',t,m,'r',t,s,'m');
title('pulse width modulated signal');
xlabel('time');
ylabel('amplitude');
RESULT
0.8
0.6
0.4
0.2
am plitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time
7
EXPERIMENT NO:3
Date : 07-07-2010
LINEAR CONVOLUTION , CIRCULAR CONVOLUTION,
AND LINEAR CONVOLUTION USING CIRCULAR
CONVOLUTION
8
h=[zeros(1,i-1),a];
p=[g,zeros(1,i-1)];
for j=1:i;
c=c+(p(j+v-1)*h(j+v-1));
end;
s(i)=c;
c=0;
end;
stem(s,'r');
xlabel('time');
ylabel('amplitude');
title('convoluted sequence');
RESULT
convoluted sequence
18
16
14
12
amplitude
10
0
1 1.5 2 2.5 3 3.5 4 4.5 5
time
9
%linear convolution with function
clear all;
clc;
clf;
x=input('input sequence x[n]=');
lx=input('starting time index of x[n]=');
h=input('impulse response h[n]=');
lh=input('starting time index of h[n]=');
y=conv(x,h);
n=lx+lh:length(y)+lx+lh-1;
stem(n,y);
title(‘convoluted sequence’);
ylabel('amplitude');
xlabel('time index');
RESULT
10
convoluted sequence
18
16
14
12
amplitude
10
0
-4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0
time index
11
title('circular convolution');
xlabel('time index');
ylabel('amplitude');
RESULT
enter the sequence x[n]=[1 2 3]
enter the sequence h[n]=[2 3 4]
circular convolution
20
18
16
14
12
amplitude
10
0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
time index
clc;
clf;clear all;
a=input('enter the sequence x[n]=');
b=input('enter the sequence h[n]=');
na=length(a);
nb=length(b);
c=[a zeros(1,nb-1)];
d=[b zeros(1,na-1)];
N1=length(c);
N2=length(d);
N=max(N1,N2);
12
c=[c zeros(1,N-N1)];
d=[d zeros(1,N-N2)];
for n=0:N-1
y(n+1)=0;
for i=0:N-1
j=mod(n-i,N);
y(n+1)=y(n+1)+c(i+1)*d(j+1);
end;
end;
stem(y);
title('linear convolution using circular convolution');
xlabel('time index');
ylabel('amplitude');
RESULT
16
14
12
amplitude
10
0
1 1.5 2 2.5 3 3.5 4 4.5 5
time index
13