0% found this document useful (0 votes)
16 views

code_script

The document outlines a MATLAB script for simulating amplitude modulation (AM) with two modulating signals and a carrier signal. It includes steps for generating baseband signals, modulating them, performing frequency analysis, synchronous demodulation, and applying a low-pass filter. Finally, it visualizes the modulating signals, carrier signal, modulated signal, frequency spectrum, and the demodulated signal through various plots.
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)
16 views

code_script

The document outlines a MATLAB script for simulating amplitude modulation (AM) with two modulating signals and a carrier signal. It includes steps for generating baseband signals, modulating them, performing frequency analysis, synchronous demodulation, and applying a low-pass filter. Finally, it visualizes the modulating signals, carrier signal, modulated signal, frequency spectrum, and the demodulated signal through various plots.
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/ 5

// Rudraj Dhuri

clc;

clear;

// Define parameters

fs = 100; // Sampling frequency

t = 0:1/fs:10-1/fs; // Time vector

// Signal parameters

fc = 30; // Carrier frequency

fm1 = 5; // Modulating frequency 1

fm2 = 10; // Modulating frequency 2

Vc = 20; // Amplitude of carrier signal

Vm1 = 10; // Amplitude of modulating signal 1

Vm2 = 5; // Amplitude of modulating signal 2

// Calculate baseband signals

vm1 = Vm1 * cos(2 * %pi * fm1 * t); // Modulating signal 1

vm2 = Vm2 * cos(2 * %pi * fm2 * t); // Modulating signal 2

vm_combined = vm1 + vm2; // Combined modulating signal

// Calculate the carrier signal

vc = Vc * cos(2 * %pi * fc * t); // Carrier signal

// Calculate the modulated signal

ma = (Vm1 + Vm2) / Vc; // Modulation index


vam = Vc * (1 + ma * vm_combined) .* vc; // Modulated signal

// Frequency analysis

l = length(t);

f = (-l/2:l/2-1) * fs / l;

y = abs(fftshift(fft(vam)));

// Synchronous Demodulation

v_m_det = vam .* vc; // Multiply modulated signal by the carrier signal

// Low-Pass Filter (LPF) Design

lpf = [ones(1, 4 * fm2), zeros(1, l - 4 * fm2)]; // Simple LPF response

v_m_demod_spec = abs(fft(v_m_det)) .* lpf; // Frequency domain profile of demodulated signal

// Inverse FFT to get time-domain signal

v_m_demod = real(ifft(v_m_demod_spec));

// Plotting

clf; // Clear current figure

figure(1) ;

// Plot modulating signal

subplot(3,1,1) ;

plot(t, vm1);

title("Baseband Signal 1");

xlabel("Time (s)");
ylabel("Amplitude");

xgrid();

// Plot modulating signal 2

subplot(3,1,2) ;

plot(t, vm2);

title("Baseband Signal 2");

xlabel("Time (s)");

ylabel("Amplitude");

xgrid();

// Plot combined modulating signals

subplot(3,1,3) ;

plot(t, vm_combined);

title("Combined Baseband Signals");

xlabel("Time (s)");

ylabel("Amplitude");

xgrid();

figure(2)

// Plot carrier signal

subplot(2,1,1) ;

plot(t, vc);

title("Carrier Signal");

xlabel("Time (s)");
ylabel("Amplitude");

xgrid();

// Plot modulated signal

subplot(2, 1, 2);

plot(t, vam);

title("Modulated Signal");

xlabel("Time (s)");

ylabel("Amplitude");

xgrid();

figure(3)

// Plot frequency spectrum

subplot(2,1,1) ;

plot(f, y);

title("Frequency Spectrum");

xlabel("Frequency (Hz)");

ylabel("Magnitude");

xgrid();

// Plot demodulated signal in the time domain

subplot(2,1,2) ;

plot(t, v_m_demod);

title("Demodulated Signal");

xlabel("Time (s)");
ylabel("Amplitude");

xgrid();

You might also like