12314
12314
%% Modulation index
h = 65;
T = 4.4 * pi
%% Message Signal :
Am = 4.7;
fm = 700;
ym = Am * cos(T * fm * t);
figure;
subplot(4, 1, 1);
plot(t(1:10000), ym(1:10000));
title('Message Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Carrier Signal :
Ac = Am / h;
fc = 6500;
yc = Ac * cos(T * fc * t);
subplot(4, 1, 2);
plot(t(1:10000), yc(1:10000));
title('Carrier Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Modulated Signal :
y = ammod(ym, fc, 100000, 0, Ac);
subplot(4, 1, 3);
plot(t(1:10000), y(1:10000));
title('Modulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Demodulated Signal :
z = amdemod(y, fc, 100000, 0, Ac);
subplot(4, 1, 4);
plot(t(1:10000), z(1:10000));
title('Demodulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
ylim([-10, 10]);
2-ish
fs = 5000;
Ac = 2;
Am = 5.7;
T= 8*pi;
fm = 100;
fc = 1000;
h=70;
B = 10;
t = (0:.1*fs)/fs;
wc = T *fc;
wm = T *fm;
m_t = Am*cos(wm*t);
subplot(4,1,1);
plot(t,m_t);
title('Message Signal');
c_t = Ac*cos(wc*t);
subplot(4,1,2);
plot(t,c_t);
title('Carrier Signal');
s_t = Ac*cos((wc*t)+h*sin(wm*t));
subplot(4,1,3);
plot(t,s_t);
title('Frequency Modulated Signal');
d = demod(s_t,fc,fs,'fm');
subplot(4,1,4);
plot(t,d);
title('Demodulated Signal');
3-ish
fs =4000;
T = 4.4 * pi
t = 0:1/fs:T;
fm = 7;
x = sin(2*pi*fm*t); % message signal
fc = 65; % carrier signal frequency
y = cos(2*pi*fc*t); % carrier signal
phasedev = pi/6; % phase deviation
phasemod = pmmod(x,fc,fs,phasedev); % modulated signal
phasedemod = pmdemod(phasemod,fc,fs,phasedev); % demodulated
signal
subplot(4,1,1);
plot(t,x);
title('Message Signal');
subplot(4,1,2);
plot(t,y);
title('Carrier Signal');
subplot(4,1,3);
plot(t,phasemod);
title('Phase Modulated Signal');
subplot(4,1,4);
plot(t,phasedemod);
title('Demodulated Signal');
4-ish
>>>>>>>>>>>>>>>>>>>>
clc, clear all, close all;
% ******************* Digital/Binary input information ********************
x = input('Enter Digital Input Information = '); % Binary information as
stream of bits (binary signal 0 or 1)
N = length(x);
Tb = 1; %Data rate = 1MHz i.e., bit period (second)
disp('Binary Input Information at Transmitter: ');
disp(x);
% ************* Represent input information as digital signal *************
nb = 100; % Digital signal per bit
digit = [];
for n = 1:1:N
if x(n) == 1;
sig = ones(1,nb);
else x(n) == 0;
sig = zeros(1,nb);
end
digit = [digit sig];
end
t1 = Tb/nb:Tb/nb:nb*N*(Tb/nb); % Time period
figure('Name','ASK Modulation and Demodulation','NumberTitle','off');
subplot(3,1,1);
plot(t1,digit,'LineWidth',2.5);
grid on;
axis([0 Tb*N -0.5 1.5]);
xlabel('Time(Sec)');
ylabel('Amplitude(Volts)');
title('Digital Input Signal');
% **************************** ASK Modulation
*****************************
Ac1 = 10.8; % Carrier amplitude for binary input '1'
Ac2 = 2; % Carrier amplitude for binary input '0'
br = 1/Tb; % Bit rate
Fc = br*6; % Carrier frequency
t2 = Tb/nb:Tb/nb:Tb; % Signal time
mod = [];
for (i = 1:1:N)
if (x(i) == 1)
y = Ac1*cos(2*pi*Fc*t2); % Modulation signal with carrier signal 1
else
y = Ac2*cos(2*pi*Fc*t2); % Modulation signal with carrier signal 2
end
mod = [mod y];
end
t3 = Tb/nb:Tb/nb:Tb*N; % Time period
subplot(3,1,2);
plot(t3,mod);
xlabel('Time(Sec)');
ylabel('Amplitude(Volts)');
title('ASK Modulated Signal');
% ********************* Transmitted signal x ******************************
x = mod;
% ********************* Channel model h and w
*****************************
h = 1; % Signal fading
w = 0; % Noise
% ********************* Received signal y
*********************************
y = h.*x + w; % Convolution
% *************************** ASK Demodulation
****************************
s = length(t2);
demod = [];
for n = s:s:length(y)
t4 = Tb/nb:Tb/nb:Tb; % Time period
c = cos(2*pi*Fc*t4); % Carrier signal
mm = c.*y((n-(s-1)):n); % Convolution
t5 = Tb/nb:Tb/nb:Tb;
z = trapz(t5,mm); % Intregation
rz = round((2*z/Tb));
Ac = ((Ac1 + Ac2)/2); % Average of carrier amplitudes
if(rz > Ac) % Logical condition
a = 1;
else
a = 0;
end
demod = [demod a];
end
disp('Demodulated Binary Information at Receiver: ');
disp(demod);
% ********** Represent demodulated information as digital signal
**********
digit = [];
for n = 1:length(demod);
if demod(n) == 1;
sig = ones(1,nb);
else demod(n) == 0;
sig = zeros(1,nb);
end
digit = [digit sig];
end
t5 = Tb/nb:Tb/nb:nb*length(demod)*(Tb/nb); % Time period
subplot(3,1,3)
plot(t5,digit,'LineWidth',2.5);grid on;
axis([0 Tb*length(demod) -0.5 1.5]);
xlabel('Time(Sec)');
ylabel('Amplitude(Volts)');
title('ASK Demodulated Signal');
% ************************** End of the program
***************************
5-ish
clc;
clear all;
close all;
for i = 1:N
if x(i) == 1
y = Ac * cos(2 * pi * Fc1 * t2);
else
y = Ac * cos(2 * pi * Fc2 * t2);
end
mod = [mod y];
end
% Decision logic
if rz1 > Ac / 2
a = 1;
else
a = 0;
end
6-ish
>>>>>>>>>>>>>>>>>>>>
clc;
clear all;
close all;
for i = 1:N
if x(i) == 1
y = Ac * cos(2 * pi * Fc1 * t2);
else
y = Ac * cos(2 * pi * Fc2 * t2);
end
mod = [mod y];
end
% Decision logic
if rz1 > Ac / 2
a = 1;
else
a = 0;
end