code_script
code_script
clc;
clear;
// Define parameters
// Signal parameters
// Frequency analysis
l = length(t);
f = (-l/2:l/2-1) * fs / l;
y = abs(fftshift(fft(vam)));
// Synchronous Demodulation
v_m_demod = real(ifft(v_m_demod_spec));
// Plotting
figure(1) ;
subplot(3,1,1) ;
plot(t, vm1);
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();
subplot(3,1,2) ;
plot(t, vm2);
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();
subplot(3,1,3) ;
plot(t, vm_combined);
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();
figure(2)
subplot(2,1,1) ;
plot(t, vc);
title("Carrier Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();
subplot(2, 1, 2);
plot(t, vam);
title("Modulated Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();
figure(3)
subplot(2,1,1) ;
plot(f, y);
title("Frequency Spectrum");
xlabel("Frequency (Hz)");
ylabel("Magnitude");
xgrid();
subplot(2,1,2) ;
plot(t, v_m_demod);
title("Demodulated Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid();