Last active 1 month ago

krolyxon revised this gist 1 month ago. Go to revision

1 file changed, 32 insertions

frequency_modulation.m(file created)

@@ -0,0 +1,32 @@
1 + clc;
2 + clear;
3 + close all;
4 +
5 + % Parameters
6 + fs = 1000; % Sampling frequency
7 + t = 0:1/fs:1; % Time vector
8 + fm = input("Enter message frequency: "); % Message frequency
9 + fc = input("Enter carrier frequency: "); % Carrier frequency
10 + Ac = input("Enter carrier amplitude: "); % Carrier amplitude
11 + Am = input("Enter message signal amplitude: ");
12 + ka = 0.8; % Modulation index (keep <= 1)
13 +
14 + % Message signal
15 + m = sin(2*pi*fm*t);
16 +
17 + % AM signal
18 + am_signal = Ac * (1 + ka*m) .* cos(2*pi*fc*t);
19 +
20 + % Plot
21 + figure;
22 +
23 + subplot(3,1,1);
24 + plot(t, m);
25 + title('Message Signal');
26 + xlabel('Time'); ylabel('Amplitude');
27 +
28 + subplot(3,1,2);
29 + plot(t, am_signal);
30 + title('AM Signal');
31 + xlabel('Time'); ylabel('Amplitude');
32 +
Newer Older