0% found this document useful (0 votes)
17 views9 pages

% Message Signal % Carrier Signal Frequency % Carrier Signal % Phase Deviation % Modulated Signal % Demodulated Signal

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views9 pages

% Message Signal % Carrier Signal Frequency % Carrier Signal % Phase Deviation % Modulated Signal % Demodulated Signal

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

4-Topshiriq

fs = 6000;
t = 0:1/fs:1;
fm = 2;
x = cos(7*pi*fm*t); % message signal
fc = 40; % carrier signal frequency
y = sin(7*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');
5-amaliy ish

KOD FRAGMENTI:

% <<<<<<<<<<<<<<<<<<<< ASK Modulation and Demodulation >>>>>>>>>>>>>>>>>>>>

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 = 9; % Carrier amplitude for binary input '1'

Ac2 = 2; % Carrier amplitude for binary input '0'

br = 1/Tb; % Bit rate

Fc = br*8; % 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 ***************************

6-amaliy ish

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','FSK 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');

% **************************** FSK Modulation *****************************

Ac = 10; % Carrier amplitude for binary input

br = 1/Tb; % Bit rate

Fc1 = br*8; % Carrier frequency for binary input '1'

Fc2 = br*6.2; % Carrier frequency for binary input '0'

t2 = Tb/nb:Tb/nb:Tb; % Signal time

mod = [];

for (i = 1:1:N)

if (x(i) == 1)

y = Ac*cos(2*pi*Fc1*t2); % Modulation signal with carrier signal 1

else

y = Ac*cos(2*pi*Fc2*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('FSK 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

% *************************** FSK Demodulation ****************************

s = length(t2);

demod = [];

for n = s:s:length(y)

t4 = Tb/nb:Tb/nb:Tb; % Time period

c1 = cos(2*pi*Fc1*t4); % carrier signal for binary value '1'

c2 = cos(2*pi*Fc2*t4); % carrier siignal for binary value '0'

mc1 = c1.*y((n-(s-1)):n); % Convolution

mc2 = c2.*y((n-(s-1)):n); % Convolution

t5 = Tb/nb:Tb/nb:Tb;

z1 = trapz(t5,mc1); % Intregation

z2 = trapz(t5,mc2); % Intregation

rz1 = round(2*z1/Tb);

rz2 = round(2*z2/Tb);

if(rz1 > Ac/2) % Logical condition


a = 1;

else(rz2 > Ac/2)

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('FSK Demodulated Signal');

% ************************** End of the program ***************************

You might also like