Pages

Wednesday, 14 November 2012

Pulse Width Modulation (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.001:1;
fc = input('Enter the frequency of carrier signal (sawtooth) = ');
fm = input('Enter the frequency of message signal (sine) = ');
a = input('Enter the amplitude of carrier signal = ');
b = input('Enter the amplitude of message signal(should be < Carrier) = ');
vc = a.*sawtooth(2*pi*fc*t);
vm = b.*sin(2*pi*fm*t);

n = length(vc);
for i = 1:n
    if (vm(i)>=vc(i))
        pwm(i) = 1;
    else
        pwm(i) = 0;
    end
end
subplot(3,1,1);
plot(t,vm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Message Signal');
grid on;
subplot(3,1,2);
plot(t,vc);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Carrier Signal');
grid on;
subplot(3,1,3);
plot(t,pwm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('PWM Signal');
axis([0 1 0 2]);
grid on;


Output:

Enter the frequency of carrier signal (sawtooth) = 10
Enter the frequency of message signal (sine) = 1
Enter the amplitude of carrier signal = 5
Enter the amplitude of message signal(should be < Carrier) = 4 


Output Waveforms:

3 comments:

  1. thanks for your help. Could you please add the PAM (pulse amplitude modulation). I couldnt find it anywhere

    ReplyDelete
    Replies
    1. Hello Huseyin öğe
      Check the link given below for PAM....
      http://newlinecode.blogspot.in/2013/04/pulse-amplitude-modulation-matlab-2012a_27.html

      Delete
  2. hello,could you please send me the code for PSM(PULSE STEP MODULATION)

    ReplyDelete