0% found this document useful (0 votes)
29 views7 pages

PCS Programs

The document outlines several experiments involving MATLAB simulations, including pulse code modulation, binary signaling pulses, Gaussian distribution, and audio signal analysis. Each experiment includes specific aims, code snippets, and plotting instructions for visualizing the results. The experiments cover topics such as signal quantization, encoding, pulse shaping, and frequency spectrum analysis.

Uploaded by

chavanakshay1812
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)
29 views7 pages

PCS Programs

The document outlines several experiments involving MATLAB simulations, including pulse code modulation, binary signaling pulses, Gaussian distribution, and audio signal analysis. Each experiment includes specific aims, code snippets, and plotting instructions for visualizing the results. The experiments cover topics such as signal quantization, encoding, pulse shaping, and frequency spectrum analysis.

Uploaded by

chavanakshay1812
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/ 7

Experiment No.

7
PCM Illustration: Sampling, Quantization and
Encoding

Aim :- To write a Matlab code to simulate pulse code


modulation and demodulation system and display waveform
% Pulse code modulation and demodulation

Clc;

Clear all;

Close all;

f=2;

fs=20*f;

t=0:1/fs:1;

a=2;

% input signal

x=a*sin(2*pi*f*t);

subplot(2,2,1);

plot(t,x,'r-');

grid on;

xlabel('time');

ylabel('amplitude');

title('i/p signal');

% quantization

x1=x+a; q_op=round(x1);

subplot(2,2,2);

plot(t,q_op,'k+-');

grid on;

xlabel('time');

ylabel('amplitude');
title('quantised signal');

%encoding

enco=de2bi(q_op,'left-msb');

[m,n]=size(enco);

y3=reshape(enco',1,m*n);

t=linspace(0,1.23,1230);

for i=1:length(y3)

if y3(i)==1

signal(1,i*10-9:i*10)=1;

else

signal(1,i*10-9:i*10)=-1;

end

end

subplot(2,2,3);

plot(t,signal);

axis([0 1.23 -2 2]);

grid on;

xlabel('time');

ylabel('amplitude');

title('PCM signal');

%decoding

for i=1:length(signal)/10

if signal(1,i*10-9:i*10)==1

y4(i)=1;

else

y4(i)=0;

end

end

y5=(reshape(y4,n,m))';

deco=bi2de(y5,'left-msb');

xr=deco-a;
t=0:1/fs:1;

subplot(2,2,4);

plot(t,xr);

grid on;

xlabel('time');

ylabel('amplitude');

title('PCM demodulated signal');

Experiment No. 8
Generate a) NRZ, RZ and Raised cosine pulse b) Generate
and plot eye diagram

Aim:- To write a Matlab code to Simulate NRZ, RZ, half-


sinusoid and raised cosine pulses and generate eye diagram
for binary polar Signaling.
clc;

clear all;

close all;

warning off

%binary i/p sequence

n=[1 0 1 1 1 0 0 1];

%binary to polar conversion

for m=1:length(n)

if n(m)==1

nn(m)=2;

else nn(m)=-2;

end

end

%rz pulse shaping


i=1; a=0; b=0.5;

t=0:0.00001:length(n);

for j=1:length(t)

if t(j)>=a && t(j)<=b

y(j)=nn(i);

elseif t(j)>b && t(j)<=i

y(j)=0;

else i=i+1;

a=a+1;

b=b+1;

end

end

subplot(2,1,1);

plot(t,y,'k');

grid on;

axis([0 length(n) -3 3]);

title('rz polar waveform');

ylabel('time');

xlabel('amplitude');

%nrz pulse shaping

i=1;

t=0:0.00001:length(n);

for j=1:length(t)

if t(j) <i

y(j)==nn(i);

else

i=i+1;

end

end

subplot(2,1,2);

plot(t,y,'k');
grid on;

axis([0 length(n) -3 3]);

title('nrz polar waveform');

xlabel('time');

ylabel('amplitude');

ii). Raised Cosine and Eye Diagram:


%raised cosine and eye diagram

clc;

clear all;

close all;

x=[1 1 1 0 0 1 0 1 1 0];

fs=20;

fd=1;

%rasied cosine

y=rcosine(fd,fs);

figure(1);

plot(y);

title('Raised cosine');

%eye diagram

delay=5;

%r=input('enter roll off factor:');

r=0.5;

rcv=rcosflt(x,fd,fs,'fir/normal',r,delay);

n=fs/fd;

eyediagram(rcv,n);
Experiment No. 9
Generate the Probability density function of Gaussian
distribution function

AIM: To write a MATLAB program to generate the Probability


density function of Gaussian distribution function

% Parameters

mu = 0;% Mean of the Gaussian distribution

sigma = 1;% Standard deviation of the Gaussian distribution

% Define range for x-axis

x = -5:0.1:5;

% Compute PDF

pdf = (1 / (sigma * sqrt(2 * pi))) * exp(-(x - mu).^2 / (2 * sigma^2));

% Plot PDF

figure;

plot(x, pdf, 'b', 'LineWidth', 2);

title('Probability Density Function of Gaussian Distribution');

xlabel('x');

ylabel('PDF');

grid on;

Experiment No. 10
Display the signal and its spectrum of an audio signal

AIM: To write a MATLAB program to generate the signal and


its spectrum of an audio signal
% Load audio file

audioFile = 'your_audio_file.wav';

% Change this to your audio file path

[y, Fs] = audioread(audioFile);

% Plot the time-domain signal

t = (0:length(y)-1) / Fs;

figure;

subplot(2, 1, 1);

plot(t, y);

title('Time-Domain Signal');

xlabel('Time (s)');

ylabel('Amplitude');

% Compute the spectrum

N = length(y);

Y = fft(y);

f = (0:N-1) * Fs / N;

% Plot the spectrum subplot(2, 1, 2);

plot(f, abs(Y));

title('Frequency Spectrum');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

xlim([0, Fs/2]); % Display only positive frequencies

% You can also use the following line to display the spectrum in dB scale

plot(f, 20*log10(abs(Y)));

ylabel('Magnitude (dB)');

% Adjust plot

grid on;

You might also like