summaryrefslogtreecommitdiff
path: root/1592/CH1/EX1.7/Example1_7.sce
blob: 955fcf84815005df8f597102c6d90ce44291b176 (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
//Scilab Code for Example 1.7 of Signals and systems by
//P.Ramakrishna Rao
clear;
clc;
function [y]=u(t)
    if t>=0
    y=1
else y=0
    end
endfunction
n=1;
for t=-10:0.1:10;
    //Function for Even signal
    y1(n)=0.5*(exp(-t)*u(t)+exp(t)*u(-t));
    n=n+1;
end
a=gca();
a.x_location="origin";
a.y_location="origin";
t=-10:0.1:10;
//Plot of Even Signal
plot(t,y1);
title('y1(t)');
xlabel('Time in seconds');
n=1;
for t=-1:0.01:1;
    //Function for Odd signal
    y2(n)=0.5*(exp(-t)*u(t)-exp(t)*u(-t));
    n=n+1;
end
figure(1);
a=gca();
a.x_location="origin";
a.y_location="origin";
t=-1:0.01:1;
//Plot of Odd Signal
plot(t,y2)
disp('plotted the signal both in even and odd forms');
title('y2(t)');
xlabel('Time in seconds');