You are on page 1of 6

NOTE: For MATLAB Go to this link and sign in with google https://octave-online.

net/#

To run program type it in editor and press enter

Experiment 3 :

Aim:
To study sampling and reconstruction of sinusoidal wave using MATLAB-R2008a.
Theory:

Sampling - Sampling is the reduction of a continuous-time signal to a discrete-time signal. A


common example is the conversion of a sound wave (a continuous signal) to a sequence of
samples (a discrete-time signal).

The process of transforming back the sampled signal x(n) to the original input signal x(t) is
known as the reconstruction of the sampling signal.
FOR MATLAB

pkg load signal

clc;

clear all;

close all;

a=5

fm = 2

t = 0:1/(1000*fm) :5/fm;

s = a*sin(2*pi*fm*t);

fs = 2*fm;

p = (1+square(2*pi*fs*t))/2;

sam1 = s.*p;

p1 = (1+square(2*pi*fs*t))/2;

sam2 = s.*p1;

subplot(3,1,1);

plot(t,s);

grid on;

title('sinosuidal signal');

Xlabel('time');

Ylabel('amplitude');

subplot(3,2,3);

plot(t,sam1);
grid on;

title('sample wave 1');

Xlabel('time');

Ylabel('amplitude');

subplot(3,2,4);

plot(t,sam2);

grid on;

title('sample wave 2');

Xlabel('time');

Ylabel('amplitude');

[n,d] = butter(10,1/60);

Y = filter(n,d,sam1);

Y1 = filter(n,d,sam2);

subplot(3,2,5);

plot(t,y);

title('reconsturcted sample wave 1');

Xlabel('time');

Ylabel('amplitude');

subplot(3,2,6);

plot(t,y1);

title('reconsturcted sample wave 2');

Xlabel('time');

Ylabel('amplitude');

grid on;

pkg unload signal


FOR OCTAVE

pkg load signal

clc;

clear all;

close all;

a=3

fm = 5

t = 0:1/(1000*fm):5/fm;

s = a*sin(2*pi*fm*t);

fs = 2*fm;

p = (1+square(2*pi*fs*t))/2;

sam1 = s.*p;

p1 = (1+square(2*pi*fs*t))/2;

sam2 = s.*p1;

subplot(3,1,1);

plot(t,s);

grid on;

title('Sinosuidal signal');

xlabel('Time');

ylabel('Amplitude');

subplot(3,2,3);

plot(t,sam1);

grid on;
title('Sample wave 1');

xlabel('Time');

ylabel('Amplitude');

subplot(3,2,4);

plot(t,sam2);

grid on;

title('Sample wave 2');

xlabel('Time');

ylabel('Amplitude');

[n,d] = butter(10,1/60);

y = filter(n,d,sam1);

y = filter(n,d,sam2);

subplot(3,2,5);

plot(t,y);

title('reconstructed sample wave 1');

xlabel('Time');

ylabel('Amplitude');

grid on;

subplot(3,2,4);

plot(t,y1);

title('reconstructed sample wave 2');

xlabel('Time');

ylabel('Amplitude');

grid on;

pkg unload signal


Results

You might also like