-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep.m
76 lines (70 loc) · 1.25 KB
/
step.m
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
clc;clear all; close all;
%% unit step
t=-5:0.1:5;
l=length(t);
for i=1:l
if t(i)<0
unit_step(i)=0;
else
unit_step(i)=1;
end
end
subplot(3,2,1);
stairs(t,unit_step);
axis([-5 5 -0.2 1.2])
grid on
title('unit step cont')
xlabel('time----->')
ylabel('amplitude--->')
subplot(3,2,2);
stem(t,unit_step);
axis([-5 5 -0.2 1.2])
grid on
title('unit step disc')
xlabel('time----->')
ylabel('amplitude--->')
%% ramp plot
for i=1:l
if t(i)<0
unit_ramp(i)=0;
else
unit_ramp(i)=t(i);
end
end
subplot(3,2,3);
plot(t,unit_ramp)
axis([-5 5 -0.2 5])
title('ramp cont')
xlabel('time----->')
ylabel('amplitude--->')
grid on
subplot(3,2,4);
stem(t,unit_ramp)
axis([-5 5 -0.2 5])
title('unit ramp disc')
xlabel('time----->')
ylabel('amplitude--->')
grid on
%% exponential
a=2
for i=1:l
if t(i)<0
unit_ex(i)=0;
else
unit_ex(i)=exp(-a*t(i));
end
end
subplot(3,2,5);
plot(t,unit_ex)
axis([-5 5 -0.2 1.2])
title('exponential cont')
xlabel('time----->')
ylabel('amplitude--->')
grid on
subplot(3,2,6);
stem(t,unit_ex)
axis([-5 5 -0.2 1.2])
title('exponential disc')
xlabel('time----->')
ylabel('amplitude--->')
grid on