-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp1(basic signals).m
79 lines (67 loc) · 1.4 KB
/
exp1(basic signals).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
len = input('enter the length of the sequence:');
seq = -len:len;
y1=zeros(1,length(seq));
y1(len+1)=1;
subplot(241);
stem(seq,y1);
xlabel('Time');
ylabel('Magnitude');
title('Unit Impulse Function');
y2=ones(1,length(seq));
y2(1:len)=0;
subplot(242);
stem(seq,y2);
xlabel('Time');
ylabel('Magnitude');
title('Unit Step Function');
a=input("Enter the amp for sine function:");
y3=a*sin(seq);
subplot(243);
stem(seq,y3);
xlabel('Time');
ylabel('Magnitude');
title('Sine');
%Exponential Function
pos_seq = 0 : 1 : len ;
a = input('Enter value of a : ' );
k = input('Enter value of k : ' );
y4 = k*a.^pos_seq;
subplot(244);
stem(pos_seq,y4)
ylabel('Mag');
xlabel('Time');
title('Exponential Sequence');
impulse=(seq==0);
unit_step=(seq>=0);
ramp=(seq.*unit_step);
subplot(245);
stem(seq,ramp);
xlabel('Time');
ylabel('Magnitude');
title('Unit Ramp');
y5=sign(seq);
subplot(246);
stem(seq,y5);
xlabel('Time');
ylabel('Magnitude');
title('Signum Function');
b=input("Enter amp of the complex number");
c=input("Enter the real part:");
d=input("Enter the img part:");
%Complex Function
A = input('Enter value of A : ' );
B = input('Enter value of B : ' );
y7 = k * (A+1i*B).^ pos_seq ;
subplot(247);
stem(pos_seq,real(y7));
ylabel('y7');
xlabel('n');
title('Real Complex Sequence');
subplot(248);
axis([-150 15 0.01 0.05]);
stem(pos_seq,imag(y7));
ylabel('y8');
xlabel('n');
title('Imaginary Complex Sequence');