Showing posts with label sampling rate conversion. Show all posts
Showing posts with label sampling rate conversion. Show all posts

MATLAB program for sampling rate conversion

Program Code
%sampling rate conversion
clc;
close all;
clear all;
N=input('Enter the length of the sequence N= ');
n=0:N-1;
f1=input('Enter the first frequency component of the signal f1= ');
f2=input('Enter the second frequency component of the signal f2= ');
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
L=input('Input the up sampling factor L= ');
x1=zeros(1,L*N);
n1=1:L*N;
a=1:L:L*N;
x1(a)=x;
M=input('Input the down sampling rate M= ');
x2=x1(1:M:(L*N));
n2=1:((L*N)/M);
subplot(311);
stem(n,x);
xlabel('discrete frequency');
ylabel('Amplitude');
title('input sequence');
grid on;
subplot(312);
stem(n1,x1);
xlabel('discrete frequency');
ylabel('Amplitude');
title('up sampled sequence');
grid on;
subplot(313);
stem(n2,x2);
xlabel('discrete frequency');
ylabel('Amplitude');
title('down sampled sequence');
grid on;



Example of Output
Enter the length of the sequence N= 100
Enter the first frequency component of the signal f1= 1000
Enter the second frequency component of the signal f2= 250
Input the up sampling factor L= 3
Input the down sampling rate M= 2



____________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .