Академический Документы
Профессиональный Документы
Культура Документы
AIM: -
SOFTWARE USED: -
MATLAB
MATLAB CODE: -
function [Ur Pr Br Mr Sr]=nrzRx(U,P,B,M,S)
% 'a' is input data sequence
% U = Unipolar, P=Polar, B=Bipolar, M=Mark and S=Space
%Wave formatting
%Unipolar
U=[1 0 0 1 1]
Ur=U;
P=[1 -1 -1 1 1];
n= length(P);
%POLAR
Pr=P;
l=find(Pr<0);
Pr(l)=0
%Bipolar
B=[ 1 0 0 -1 1]
n= length(B);
Br=B;
l=find(Br<0);
Br(l)=1;
%Mark
M=[1 0 0 0 1 0]
n= length(M);
for k=1:n-1;
Mr(k)=xor(M(k), M(k+1));
end
%Space
S=[ 1 1 0 1 1]
n= length(S);
S(1)=1;
for k=1:n-1
Sr(k)=not(xor(S(k), S(k+1)));
end
%Plotting Waves
n= length(Ur);
subplot(5, 1, 1); stairs(Ur)
axis([1 n+2 -2 2])
title('Unipolar NRZ Decoded')
grid on
n= length(P);
subplot(5, 1, 2); stairs(P)
axis([1 n+2 -2 2])
title('Polar NRZ Decoded')
grid on
n= length(Br);
subplot(5, 1, 3); stairs(B)
axis([1 n+2 -2 2])
title('Bipolar NRZ Decoded')
grid on
n= length(Mr);
subplot(5, 1, 4); stairs(M)
axis([1 n+2 -2 2])
title('NRZ-Mark Decoded')
grid on
n= length(Sr);
subplot(5, 1, 5); stairs(S)
axis([1 n+2 -2 2])
title('NRZ-Space Decoded')
grid on
OUTPUT: -
RACTICAL NO 4
AIM: -
SOFTWARE USED: -
MATLAB
MATLAB CODE: -
clc;
clear all;
close all;
s= [1 0 1 0];
f1=20;
a=length (s);
for i=1:a
f=f1*s (1,i);
for t=(i-1)*100+1:i*100
x(t)=sin(2*pi*f*t/1000);
end
end
plot(x);
xlabel('time in secs');
ylabel('amplitude in volts');
title('ASK')
grid on;
OUTPUT: -
RACTICAL NO 5
AIM: -
SOFTWARE USED: -
MATLAB
MATLAB CODE: -
title('Sampled Sinusoidal Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(2,2,4);
stem(sig2);
title('Sampled Triangular Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
l1=length(sig1);
l2=length(sig2);
for i=1:l1
sig(1,i)=sig1(i); % Making Both row vector to a matrix
sig(2,i)=sig2(i);
end
SOFTWARE USED: -
MATLAB
MATLAB CODE: -
clc;
clear;
clf;
td=0.002; % original sampling rate rate 500 hz
t=[0:td:1.]; %time interval of 1 sec
xsig=sin(2*pi*t)-sin(6*pi*t); %n1hz +3 hz sinusoidals
Lsig=length(xsig);
Lfft=2^ceil(log2(Lsig)+1);
Xsig=fftshift(fft(xsig,Lfft));
Fmax=1/(2*td);
Faxis=linspace(-Fmax,Fmax,Lfft);
ts=0.02; % new sampling rate =50 hz
Nfact=ts/td;
% send the signal through a 16-level uniform quantiser
[s_out,sq_out,sqh_out1,Delta,SQRN]=sampandquant(xsig,16,td,ts);
% obtaind the signal which is
% - sampled,quantiser,and zero-order hold signal sqh_out
% plot the original signal and PCM signal in time domain figrue(1);
figure(1);
subplot(211);
sfig1=plot(t,xsig,'k',t,sqh_out1(1:Lsig),'b');
set(sfig1,'Linewidth',2);
title('Signal {\it g}({{\it t}) and its 16 level PCM signal')
xlabel('time(sec.)');
B. TECH (HONS.)-ECE
RA67E3A31
7060070003