% MATLAB Script for a Binary ASK with two Amplitude Levels 
format long; 
% Clear all variables and close all figures 
clear all; 
close all; 
% The number of bits to send - Frame Length 
N = 8; 
% Generate a random bit stream 
bit_stream = round(rand(1,N)); 
% Enter the two Amplitudes 
% Amplitude for 0 bit 
A1 = 3; 
% Amplitude for 1 bit 
A2 = 5; 
% Frequency of Modulating Signal 
f = 3; 
% Sampling rate - This will define the resoultion 
fs = 100; 
% Time for one bit 
t = 0: 1/fs : 1; 
% This time variable is just for plot 
time = []; 
ASK_signal = []; 
Digital_signal = []; 
for ii = 1: 1: length(bit_stream) 
% The FSK Signal 
ASK_signal = [ASK_signal (bit_stream(ii)==0)*A1*sin(2*pi*f*t)+... 
(bit_stream(ii)==1)*A2*sin(2*pi*f*t)]; 
% The Original Digital Signal 
Digital_signal = [Digital_signal (bit_stream(ii)==0)*...
zeros(1,length(t)) + (bit_stream(ii)==1)*ones(1,length(t))]; 
time = [time t]; 
t = t + 1; 
end 
% Plot the ASK Signal 
subplot(2,1,1); 
plot(time,ASK_signal,'LineWidth',2); 
xlabel('Time (bit period)'); 
ylabel('Amplitude'); 
title('ASK Signal with two Amplitudes'); 
%axis([0 time(end) 1.5 1.5]); 
grid on; 
% Plot the Original Digital Signal 
subplot(2,1,2); 
plot(time,Digital_signal,'r','LineWidth',2); 
xlabel('Time (bit period)'); 
ylabel('Amplitude'); 
title('Original Digital Signal'); 
axis([0 time(end) -0.5 1.5]); 
grid on;
% MATLAB Script for a Binary FSK with two Amplitude Levels 
clear; 
clc; 
b = input('Enter the Bit stream n '); 
%b = [0 1 0 1 1 1 0]; 
n = length(b); 
t = 0:.01:n; 
x = 1:1:(n+1)*100; 
for i = 1:n 
if (b(i) == 0) 
b_p(i) = -1; 
else 
b_p(i) = 1; 
end 
for j = i:.1:i+1 
bw(x(i*100:(i+1)*100)) = b_p(i); 
end 
end 
bw = bw(100:end); 
wo = 2*(2*pi*t); 
W = 1*(2*pi*t); 
sinHt = sin(wo+W); 
sinLt = sin(wo-W); 
st = sin(wo+(bw).*W); 
subplot(4,1,1) 
plot(t,bw) 
grid on ; axis([0 n -2 +2]) 
subplot(4,1,2) 
plot(t,sinHt) 
grid on ; axis([0 n -2 +2]) 
subplot(4,1,3) 
plot(t,sinLt) 
grid on ; axis([0 n -2 +2]) 
subplot(4,1,4) 
plot(t,st) 
grid on ; axis([0 n -2 +2]) 
Fs=1; 
figure 
%pburg(st,10) 
periodogram(st)
% MATLAB Script for a Binary PSK with two Amplitude Levels 
clear all; %Clear all variables 
close all; %Close all figures 
l=1e6; %Number of bits or symbols 
EbNodB=0:2:10; %Range of EbNo in dB 
for n=1:length(EbNodB); 
s=2*(round(rand(1,l))-0.5); %Random symbol generation 
w=(1/sqrt(2*10^(EbNodB(n)/10)))*randn(1,l); %Random noise generation 
r=s+w; %Received signal 
s_est=sign(r); %Demodulation 
BER(n)=(l-sum(s==s_est))/l; %BER calculation 
end 
semilogy(EbNodB, BER,'o-'); %Plot 
xlabel('EbNo(dB)') %Label for x-axis 
ylabel('BER') %Label for y-axis 
grid on

bask, bfsk, bpsk

  • 1.
    % MATLAB Scriptfor a Binary ASK with two Amplitude Levels format long; % Clear all variables and close all figures clear all; close all; % The number of bits to send - Frame Length N = 8; % Generate a random bit stream bit_stream = round(rand(1,N)); % Enter the two Amplitudes % Amplitude for 0 bit A1 = 3; % Amplitude for 1 bit A2 = 5; % Frequency of Modulating Signal f = 3; % Sampling rate - This will define the resoultion fs = 100; % Time for one bit t = 0: 1/fs : 1; % This time variable is just for plot time = []; ASK_signal = []; Digital_signal = []; for ii = 1: 1: length(bit_stream) % The FSK Signal ASK_signal = [ASK_signal (bit_stream(ii)==0)*A1*sin(2*pi*f*t)+... (bit_stream(ii)==1)*A2*sin(2*pi*f*t)]; % The Original Digital Signal Digital_signal = [Digital_signal (bit_stream(ii)==0)*...
  • 2.
    zeros(1,length(t)) + (bit_stream(ii)==1)*ones(1,length(t))]; time = [time t]; t = t + 1; end % Plot the ASK Signal subplot(2,1,1); plot(time,ASK_signal,'LineWidth',2); xlabel('Time (bit period)'); ylabel('Amplitude'); title('ASK Signal with two Amplitudes'); %axis([0 time(end) 1.5 1.5]); grid on; % Plot the Original Digital Signal subplot(2,1,2); plot(time,Digital_signal,'r','LineWidth',2); xlabel('Time (bit period)'); ylabel('Amplitude'); title('Original Digital Signal'); axis([0 time(end) -0.5 1.5]); grid on;
  • 3.
    % MATLAB Scriptfor a Binary FSK with two Amplitude Levels clear; clc; b = input('Enter the Bit stream n '); %b = [0 1 0 1 1 1 0]; n = length(b); t = 0:.01:n; x = 1:1:(n+1)*100; for i = 1:n if (b(i) == 0) b_p(i) = -1; else b_p(i) = 1; end for j = i:.1:i+1 bw(x(i*100:(i+1)*100)) = b_p(i); end end bw = bw(100:end); wo = 2*(2*pi*t); W = 1*(2*pi*t); sinHt = sin(wo+W); sinLt = sin(wo-W); st = sin(wo+(bw).*W); subplot(4,1,1) plot(t,bw) grid on ; axis([0 n -2 +2]) subplot(4,1,2) plot(t,sinHt) grid on ; axis([0 n -2 +2]) subplot(4,1,3) plot(t,sinLt) grid on ; axis([0 n -2 +2]) subplot(4,1,4) plot(t,st) grid on ; axis([0 n -2 +2]) Fs=1; figure %pburg(st,10) periodogram(st)
  • 4.
    % MATLAB Scriptfor a Binary PSK with two Amplitude Levels clear all; %Clear all variables close all; %Close all figures l=1e6; %Number of bits or symbols EbNodB=0:2:10; %Range of EbNo in dB for n=1:length(EbNodB); s=2*(round(rand(1,l))-0.5); %Random symbol generation w=(1/sqrt(2*10^(EbNodB(n)/10)))*randn(1,l); %Random noise generation r=s+w; %Received signal s_est=sign(r); %Demodulation BER(n)=(l-sum(s==s_est))/l; %BER calculation end semilogy(EbNodB, BER,'o-'); %Plot xlabel('EbNo(dB)') %Label for x-axis ylabel('BER') %Label for y-axis grid on