-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoctave_PM.m
More file actions
36 lines (32 loc) · 1.22 KB
/
octave_PM.m
File metadata and controls
36 lines (32 loc) · 1.22 KB
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
clc; #... Clear command line
clear all; #... Clear variables
close all; #... Clear figures
msg_amplitude = 1; #... Amplitude of message signal
msg_frequency = 2; #... Frequency(Hz) of message signal
time = 0:0.001:03; #... Time samples
msg_signal = msg_amplitude*sin(2*pi*msg_frequency*time); #... Message signal
subplot(4,1,1);
plot(time, msg_signal);
title('Message or Modulating Signal');
carrier_amplitude = 1; #... Amplitude of carrier signal
carrier_frequency = 30; #... Frequency(Hz) of carrier signal
carrier_signal = carrier_amplitude*cos(2*pi*carrier_frequency*time); #... Carrier signal
subplot(4,1,2);
plot(time, carrier_signal);
title('Carrier Signal');
#... Modulation
kp = 10 #... Deviation sensitivity of phase modulation
modulated_signal = carrier_amplitude*cos(2*pi*carrier_frequency*time+kp*msg_signal);
subplot(4,1,3);
plot(time, modulated_signal);
title('Modulated signal using phase modulation');
#... Demodulation
x = abs(diff(modulated_signal));
#... To use butter function we need to run the following 2 commands
#... pkg install -forge signal;
pkg load signal;
[a,b] = butter(10, 0.03);
demodulated_signal = filter(a,b,x);
subplot(4,1,4);
plot(demodulated_signal);
title('Demodulated signal using phase demodulation');