MATLAB Answers

How can i generate PPM,PAM,PWM modulation and demodulation .

143 views (last 30 days)
sandhya
sandhya on 18 Aug 2011
Answered: Aena Verma on 24 Oct 2020
I have tried the function pammod also but i couldnt get the output, please help me to generate PAM,PPM,PWM.

  0 Comments

Sign in to comment.

Answers (1)

Aena Verma
Aena Verma on 24 Oct 2020
% PAM using Ideal Sampling
clc;
close all;
clear all;
a = input('Enter the amplitude = ');
f = input('Enter the frequency = ');
t = 0:0.02:2;
x1 = 1; %generation of an impulse signal
x2 = a*sin(2*pi*f*t); %generation of sine wave
y = x1.*x2; %modulation step
subpl20ot(3,1,1); %for impulse signal plot
stem(x1);
title('Impulse Signal');
xlabel('Time');
ylabel('Amplitude ');
subplot(3,1,2) %for sine wave plot
plot(t,x2);
title('Sine Wave');
xlabel('Time ');
ylabel('Amplitude ');
subplot(3,1,3) %for PAM wave plot
stem(t,y);
title('PAM Wave');
xlabel('Time');
ylabel('Amplitude');
% PAM using Natural Sampling
clc;
clear all;
close all;
fc= 100
fm= fc/10
fs= 100*fc
t=0:1/fs:4/fm;
Msg_sgl= cos(2*pi*fm*t);
Carr_sgl= 0.5*square(2*pi*fc*t)+0.5
Mod_sgl= Msg_sgl.*Carr_sgl;
tt= [];
for i=1:length(Mod_sgl);
if Mod_sgl(i)==0;
tt=[tt,Mod_sgl(i)];
else
tt=[tt,Mod_sgl(i)+2];
end
end
figure(1)
subplot(4,1,1);
plot(t,Msg_sgl);
title('Message Signal');
xlabel('Time Period');
ylabel('Amplitude');
subplot(4,1,2);
plot(t,Carr_sgl);
title('Carrier Signal')
xlabel('Time Period');
ylabel('Amplitude');
subplot(4,1,3);
plot(t,Mod_sgl);
title('PAM Modulated signal')
xlabel('Time Period');
ylabel('Amplitude');
% subplot(4,1,4);
% plot(t,tt);
% title('PAM')
% xlabel('Time Period');
% ylabel('Amplitude');
% PWM Signal
clc;
close all;
clear all;
t=0:0.0001: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,'g',t,m,'r',t,s,'b');
ylabel('Amplitude');
axis([0 1 -1.5 1.5]);
xlabel('Time index');
title('PWM Wave');
grid on;
% PPM Signal
clc;
clear all;
close all;
fc=1000;
fs=10000;
fm=200;
t=0:1/fs:((2/fm)-(1/fs));
X= 0.5*cos(2*pi*fm*t)+0.5;
Y= modulate(X,fc,fs,'PPM');
subplot(2,2,1);
plot(X);
title('Msg Signal');
subplot(2,2,2);
plot(Y);
axis([0 500 -0.2 1.2]);
title('PPM');

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!