This repository has been archived by the owner on May 26, 2020. It is now read-only.
forked from kaustubhcs/Digital-Signal-Processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrequency Modulation Experiment.m
68 lines (43 loc) · 1.86 KB
/
Frequency Modulation Experiment.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
% Frequency Modulation !
function error = fm_experiment()
clear all;
clc;
%message_choice = input('1 = Sine Wave OR 2 = Cos Wave for message signal: ');
%Am = input('Amplitude of Message signal: ');
%fm = input('Frequency of message signal: ');
%Ac = input('Amplitude of Carrier Wave: ');
%fc = input('Frequency of Carrier Wave: ');
%theeta = input('Phase difference in degrees: ');
%kf = input('Enter frequency Sensitivity: ');
jump_activated = 0;
message_choice = 2;
Am = 1;
Ac = 5;
fm = 1;
fc = 1;
kf = 10;
output_matrix = [0 : 100000];
sin_mat = [0 : 100000];
t3 = 1;
for t2 = 0 : 0.0001 :10
if message_choice == 1
phiit = 2 * pi * fc * t2 + ( ( kf * Am * sin(2 * pi * fm * t2) ) / fm);
sin_mat(t3) = Am * sin(2 * pi * fm * t2);
elseif message_choice == 2
phiit = 2 * pi * fc * t2 + ( ( kf * Am * cos(2 * pi * fm * t2) ) / fm);
sin_mat(t3) = Am * cos(2 * pi * fm * t2);
else
jump_activated = 1;
end
%disp(phiit);
output_matrix(t3) = Ac * cos(phiit);
%disp(phiit);
t3 = t3 +1;
end
if jump_activated == 0
t = [0 : 100000];
%disp(output_matrix);
%disp(t);
plot(t,output_matrix,t,sin_mat);
end
end