summaryrefslogtreecommitdiff
path: root/3176/CH4/EX4.1/Ex4_1.sce
blob: 91e00f42701485a5cce0cbd31ff9cae47f0ec083 (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
36
37
38
39
40
41
42
43
44
45
46
47
//Ex4_1
// Obtaining the Fourier Transform of a Simple Function
//Version : Scilab 5.4.1
// Operating System : Window-xp, Window-7
//Toolbox: Image Processing Design 8.3.1-1
//Toolbox: SIVP 0.5.3.1-2
//Reference book name : Digital Image Processing
//book author: Rafael C. Gonzalez and Richard E. Woods


clc; //to clear command window.
clear; //to kill previously defined variables.
xdel(winsid());//to close all currently open figure(s).

f=-5:0.01:5;
[nr nc]=size(f);
signal=ones(nr,nc);
A=1;
W=length(f);
for i=1:W
    if(f(i)==0)
        mag(i)=A;
    else
        mag(i)=A*W*(sin(%pi*f(i)*W)/((%pi*f(i)*W)+%eps));         
    end    
    
end

figure,mtlb_axis([-6 6 0 2]);
bar(f,signal,0.1);
xlabel('Time Index','color','blue','fontsize',2);
ylabel('Amplitude','color','blue','fontsize',2);
title('Rectangle Function','color','blue','fontsize',4);


figure,//mtlb_axis([-15 15 0 2]);
plot(f,mag);
xlabel('Frequency','color','blue','fontsize',2);
ylabel('Amplitude','color','blue','fontsize',2);
title('Frequency Spectrum Plot','color','blue','fontsize',4);


figure,//mtlb_axis([-15 15 0 2]);
plot(f,abs(mag));
xlabel('Frequency','color','blue','fontsize',2);
ylabel('Amplitude','color','blue','fontsize',2);
title('Frequency Spectrum Plot','color','blue','fontsize',4);