0% found this document useful (0 votes)
47 views4 pages

Experiment 2 (B) : Aim: To Write A MATLAB Program To Receive An Input Sequence From The User and To

This MATLAB program increases the sampling rate of an input sequence by inserting zeros between samples. The user enters the original sequence and upsampling factor. The program inserts the appropriate number of zeros between each original sample. It displays the original, upsampled, and upsampled using the "upsample" function plots for comparison. The program was tested by upsampling sequences by factors of 2 and 3, and the results matched those from the built-in function.

Uploaded by

Thomas James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

Experiment 2 (B) : Aim: To Write A MATLAB Program To Receive An Input Sequence From The User and To

This MATLAB program increases the sampling rate of an input sequence by inserting zeros between samples. The user enters the original sequence and upsampling factor. The program inserts the appropriate number of zeros between each original sample. It displays the original, upsampled, and upsampled using the "upsample" function plots for comparison. The program was tested by upsampling sequences by factors of 2 and 3, and the results matched those from the built-in function.

Uploaded by

Thomas James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXPERIMENT 2(b)

Aim : To write a MATLAB program to receive an input sequence from the user and to
increase its sampling rate by a user-defined factor and to verify the same using
the MATLAB in-built function.
Theory : In order to increase the sampling rate of a sequence by a factor p, (p-1)
zeros are inserted between samples. This is implemented using iteration loops.
MATLAB also has an in-built function upsample defined as upsample(x,n) which
inserts (n-1) zeros between each sample of x. This is used to verify the program.
Tool used : MATLAB R2010b
Program :
clc;
clear all;
close all;
m=input('Enter the length of the sequence : ');
for i=1:m
x(i)=input('Enter the sequence value : ');
end
p=input('Enter the upsampling factor : ');
j=1;
for i=1:m
y(j)=x(i);
for k=1:p-1
j=j+1;
y(j)=0;
end;
j=j+1;
end;
subplot(2,2,1);
stem(x);
axis([0 10 0 4]);
title('Original signal');
subplot(2,2,2);
stem(y);
axis([0 15 0 4]);
title('Up-sampled signal');
subplot(2,2,4);
z=upsample(x,p);
stem(z);
axis([0 15 0 4]);
title('Up-sampled signal using in-built');

Result :
Enter the length of the sequence : 5
Enter the sequence value : 1
Enter the sequence value : 2
Enter the sequence value : 3
Enter the sequence value : 2
Enter the sequence value : 1
Enter the up-sampling factor : 2






Enter the up-sampling factor : 3



Conclusion : Implemented a MATLAB program to accept input sequence from the
user and increased its sampling rate by 2 and 3 and obtained the results for
the same. Also verified the outputs using the MATLAB in-built function.

You might also like