23bec1231 Acslab3
23bec1231 Acslab3
close all;
clear all;
fm = 20;% msg signal frequency in Hz
Am = 1; %amplitude of msg signal in volts
fs = 10000;% sampling frequency where fs must be at least 2*fc
nc = 3;%number of cycle of msg signal
t=0:1/fs:nc/fm;% time vector
%m=Am*sin(2*pi*fm*t);% msg signal generation
dcy = 2;%duty cycle: The duty cycle is the percent of the signal period in
which the square wave is positive.
m = Am*(square(2*pi*fm*t)+dcy);% if msg signal square wave
% ploting of msg signal
subplot(4,1,1);
plot(t,m,'LineWidth',2,'Color','r');
set(gca,'fontsize',11,'fontweight','bold');% gca for current axes
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Frequency', 'fontsize', 11, 'fontweight', 'bold');
title('MessageSignal-23bec1231','fontsize',12);
fc = 100;% carrier signal frequency in Hz
Ac = 1;%amplitude of carrier signal in volts
c=Ac*sin(2*pi*fc*t);% carrier signal generation
% ploting of carrier signal
subplot(4,1,2);
plot(t,c,'LineWidth',2,'Color','b');
set(gca,'fontsize',11,'fontweight','bold');
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Frequency', 'fontsize', 11, 'fontweight', 'bold');
title('Carrier Signal', 'fontsize', 12);
% generation of FM signal
mf = 50;%frequency deviation
s=fmmod(m,fc,fs,mf);% frequency modulation function y =
fmmod(m,fc,fs,freqdev, it will give FM modulated wave
% ploting of FM signal
subplot(4,1,3)
plot(t,s,'LineWidth',2,'Color','g');
set(gca,'fontsize',11,'fontweight','bold');
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Frequency', 'fontsize', 11, 'fontweight', 'bold');
title('FM Signal', 'fontsize', 12);
%demodulation of FM signal
clc;
close all;
clear all;
fm = 20;% msg signal frequency in Hz
Am = 1; %amplitude of msg signal in volts
fs = 10000;% sampling frequency where fs must be at least 2*fc
nc = 3;%number of cycle of msg signal
t=0:1/fs:nc/fm;% time vector
%m=Am*sin(2*pi*fm*t);% msg signal generation
dcy = 2;%duty cycle: The duty cycle is the percent of the signal period in
which the square wave is positive.
m = Am*sin(2*pi*fm*t);% if msg signal square wave
% ploting of msg signal
subplot(4,1,1);
plot(t,m,'LineWidth',2,'Color','r');
set(gca,'fontsize',11,'fontweight','bold');% gca for current axes
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Amplitude', 'fontsize', 11, 'fontweight', 'bold');
title('MessageSignal-23bec1231','fontsize',12);
fc = 100;% carrier signal frequency in Hz
Ac = 1;%amplitude of carrier signal in volts
c=Ac*sin(2*pi*fc*t);% carrier signal generation
% ploting of carrier signal
subplot(4,1,2);
plot(t,c,'LineWidth',2,'Color','b');
set(gca,'fontsize',11,'fontweight','bold');
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Amplitude', 'fontsize', 11, 'fontweight', 'bold');
title('Carrier Signal', 'fontsize', 12);
% generation of FM signal
mf = 50;%frequency deviation
s=fmmod(m,fc,fs,mf);% frequency modulation function y =
fmmod(m,fc,fs,freqdev, it will give FM modulated wave
% ploting of FM signal
subplot(4,1,3)
plot(t,s,'LineWidth',2,'Color','g');
set(gca,'fontsize',11,'fontweight','bold');
xlabel('Time', 'fontsize', 11, 'fontweight', 'bold');
ylabel('Amplitude', 'fontsize', 11, 'fontweight', 'bold');
title('FM Signal', 'fontsize', 12);
%demodulation of FM signal