Ilovepdf Merged
Ilovepdf Merged
>> % 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)
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');
28/1/25 11:12 AM MATLAB Command Window 2 of 2
>>
>>
>>
MATLAB Command Window Page 1
end
% Plot the PSK Signal
subplot(2,1,1);
plot(time,PSK_signal,'LineWidth',2);
xlabel('Time (bit period)');
ylabel('Amplitude');
title('PSK Signal with two Phase Shifts');
axis([0 time(end) -1.5 1.5]);
MATLAB Command Window Page 2
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;
>>
% Experiment No-4 : Simulation of Delta Modulation using MATLAB
%%===============================================
clc;
t=0:2*pi/100:2*pi; % Time Duration
x=5*sin(2*pi*t/5); % Define Message Signal with peak voltage 5V and frequency
5Hz
plot(x)
hold on
y=[0]; %Output DM signal i.e. stream of 1 or 0
xr=0; % Output of Integrator i.e. staircase approximation; initial value =0
del=0.4; % Stepsize
for i=1:length(x)-1
if xr(i)<=x(i) % If current sample greater than the previous values or
output of the integrator, output of DM=1
d=1;
xr(i+1)=xr(i)+del; % Staircase approximated value
else
d=0;
xr(i+1)=xr(i)-del; % If current sample less than the previous values
or output of the integrator, output of DM=0
end
y=[y d];
end
stairs(xr); % Show the staircase approximated signal
hold off
MSE=sum((x-xr).^2)/length(x) % MSE
y % Output of DM
MATLAB Command Window Page 1
subplot(2,1,2);
plot(dsss);
title('DS-SS Signal');