0% found this document useful (0 votes)
10 views10 pages

AMFM

The document contains MATLAB code for both Amplitude Modulation (AM) and Frequency Modulation (FM) signal generation and analysis. It includes parameters for message and carrier signals, plots for time domain and frequency domain representations, as well as power spectrum calculations. The code demonstrates how to visualize the modulated signals and their respective spectra.

Uploaded by

SHYAM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

AMFM

The document contains MATLAB code for both Amplitude Modulation (AM) and Frequency Modulation (FM) signal generation and analysis. It includes parameters for message and carrier signals, plots for time domain and frequency domain representations, as well as power spectrum calculations. The code demonstrates how to visualize the modulated signals and their respective spectra.

Uploaded by

SHYAM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MATLAB PROGRAM: AMPLITUDE MODULATION

clc; clear; close all;


% Parameters
Am = 1; % Message amplitude
Ac = 1; % Carrier amplitude
fm = 5e3; % Message frequency (5 kHz)
fc = 100e3; % Carrier frequency (100 kHz)
fs = 1e6; % Sampling frequency (1 MHz)
t = 0:1/fs:1e-3; % Time vector (1 ms duration)

m = Am * sin(2*pi*fm*t); % Message signal


c = Ac * sin(2*pi*fc*t); % Carrier signal

% AM Modulation
ka = 0.5; % Modulation index (50%)
s = (1 + ka*m) .* c; % AM signal

% Time Domain Plots


figure(1);
subplot(3,1,1);
plot(t*1e3, m, 'b', 'LineWidth', 1.2);
title('Message Signal (5 kHz)');
xlabel('Time (ms)'); ylabel('Amplitude'); grid on;

subplot(3,1,2);
plot(t*1e3, c, 'r', 'LineWidth', 1.2);
title('Carrier Signal (100 kHz)');
xlabel('Time (ms)'); ylabel('Amplitude'); grid on;

subplot(3,1,3);
plot(t*1e3, s, 'k', 'LineWidth', 1.2);
title('AM Modulated Signal');
xlabel('Time (ms)'); ylabel('Amplitude'); grid on;
% Frequency Domain (Two-sided Spectrum)
N = length(s);
S_f = fftshift(fft(s)/N);
f = (-N/2:N/2-1)*(fs/N);

figure(2);
plot(f/1e3, abs(S_f), 'LineWidth', 1.2);
title('Two-Sided Spectrum of AM Signal');
xlabel('Frequency (kHz)'); ylabel('Magnitude'); grid on;
xlim([-150 150]);
% Power Spectrum using pspectrum and log scale
[P, f] = pspectrum(s, fs, 'FrequencyLimits', [0 200e3],'Leakage',0); % Compute power spectrum
figure(3);
plot(f/1e3, 10*log10(P), 'LineWidth', 1.3);
title('Power Spectrum of AM Signal (in dB Scale)');
xlabel('Frequency (kHz)');
ylabel('Power (dB)');
grid on;
xlim([0 200]);
OUTPUT :
TIME DOMAIN PLOT OF AM SIGNAL (50% MODULATION)

TIME DOMAIN PLOT OF AM SIGNAL (30% MODULATION)


TIME DOMAIN PLOT OF AM SIGNAL (80% MODULATION)

MAGNITUDE SPECTRUM OF AM SIGNAL


POWER SPECTRUM OF AM SIGNAL:
Pspectrum command

FFT Magnitude Squared


MATLAB PROGRAM: FM MODULATION
clc; clear; close all;

% --- Parameters ---


Am = 1; % Message amplitude
Ac = 1; % Carrier amplitude
fm = 5e3; % Message frequency (5 kHz)
fc = 100e3; % Carrier frequency (100 kHz)
fs = 1000e3; % Sampling frequency (1 MHz)
t = 0:1/fs:1e-3; % 1 ms duration

% --- FM Parameters ---


Df = 50e3; % Frequency deviation (50 kHz)
beta = Df / fm; % Modulation index

% --- Message, Carrier, FM Signal ---


m = Am * sin(2*pi*fm*t); % Message signal
c = Ac * sin(2*pi*fc*t); % Carrier signal
s = Ac * cos(2*pi*fc*t + beta * sin(2*pi*fm*t)); % FM signal

figure(1);
subplot(3,1,1);
plot(t*1e3, m, 'b', 'LineWidth', 1.2);
title('Message Signal (5 kHz)');
xlabel('Time (ms)'); ylabel('Amplitude');
grid on;

subplot(3,1,2);
plot(t*1e3, c, 'r', 'LineWidth', 1.2);
title('Carrier Signal (100 kHz)');
xlabel('Time (ms)');
ylabel('Amplitude');
grid on;

subplot(3,1,3);
plot(t*1e3, s, 'k', 'LineWidth', 1.2);
title('FM Modulated Signal');
xlabel('Time (ms)');
ylabel('Amplitude');
grid on;

N = length(s);
S_f = fftshift(fft(s)/N); % FFT + shift
f = (-N/2:N/2-1)*(fs/N); % Frequency axis

figure(2);
plot(f/1e3, abs(S_f), 'LineWidth', 1.2);
title('Two-Sided Spectrum of FM Signal (FFT Based)');
xlabel('Frequency (kHz)');
ylabel('Magnitude');
grid on;
xlim([-200 200]); % zoom near carrier region
OUTPUT
TIME DOMAIN PLOT OF FM SIGNAL (β = 10)

MAGNITUDE SPECTRUM
TIME DOMAIN PLOT OF FM SIGNAL (β = 1)

MAGNITUDE SPECTRUM
POWER SPECTRUM OF FM SIGNAL

You might also like