-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation_on_signal.asv
71 lines (57 loc) · 2.6 KB
/
operation_on_signal.asv
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
function signal_modifed = operation_on_signal(t,signal)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
prompt = 'Do you want to perform any operation on the signal? (yes/no)\n';
answer = input(prompt,'s');
if strcmp(answer , 'yes')
fprintf('The operations you can perform on the signal are:\na-Amplitude Scaling, \nb-Time reversal, \nc-Time shift, \nd-Expanding the signal, \ne-Compressing the signal, \nf-None\n\n');
prompt = 'Enter the number of operations you want to perform (from 1 to 5): ';
num_operations = input(prompt);
figure_num = 2;
while (num_operations > 0)
prompt = 'Enter the name of operations you want to perform\ntype a or b or c or d or e or f: ';
operation = input(prompt, 's');
%a
if strcmp(operation, 'a')
prompt = 'Enter the valule of amplification: ';
amp = input(prompt);
signal_modifed = amp*signal;
figure(figure_num)
plot(t,signal_modifed)
%b
elseif strcmp(operation,'b')
time = -1.*t;
figure(figure_num)
plot(time,signal_modifed)
%c
elseif strcmp(operation,'c')
prompt ='enter the value of the shift: ';
shift = input(prompt);
time= t-shift;
figure(figure_num)
plot(time,signal_modifed)
%d
elseif strcmp(operation,'d')
prompt ='enter the value of a which a<1 & a>0: ';
expan = input(prompt);
time= expan*t;
figure(figure_num)
plot(time,signal_modifed)
%e
elseif strcmp(operation,'e')
prompt ='enter the value of a which a>1: ';
comp = input(prompt);
time = t./comp;
figure(figure_num)
plot(time,signal_modifed)
%f
elseif strcmp(operation,'f')
signal_modifed = signal;
end
num_operations = num_operations -1;
figure_num = figure_num +1;
end
elseif strcmp(answer , 'no')
signal_modifed = signal;
end
end