summaryrefslogtreecommitdiff
path: root/2303/CH10/EX10.1/10_1.sce
blob: 7b61735e42b13eb0e88b8b466a3e45cc1bfde027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Example 10.1

clc;
close;
clear;
fx=8000;    //sampling frequency of original signal

//Plotting original sequence
for f=1:1024
    original(f)=sin(2*180*f/(fx/2));    
end
subplot(2,1,1);
plot2d3(original);
title('Original sequence');
xlabel('Frequency');
ylabel('Amplitude');

df=2;       //decimation factor
decimated=[];
n=1;

//Decimation
for i=1:length(original)                
    if modulo(i,df)~=0
        decimated(n)=original(i);
        n=n+1;
    end
end

//Plotting decimated sequence
subplot(2,1,2);
plot2d3(decimated);
title('Decimatated sequence');
xlabel('Frequency');
ylabel('Amplitude');