%
% mdln.m *****  MatLab Modulation Script  *****
%
TWOPI = 2*pi;
fc = input('What is the carrier frequency (in MHz)? ');
fc = fc * 1e6;
OMEGA_C = TWOPI*fc;
fm = input('What is the modulation frequency (in KHz)? ');
fm = fm * 1000;
OMEGA_M = TWOPI*fm;
%
Tm = 1.49/fm;                         % Plot 3 periods
t = linspace(0,Tm,2048);
%
fprintf('Plotting DSB-SC in Figure No. 1\n')
figure(1)
sc = cos(OMEGA_M*t).*cos(OMEGA_C*t);  % DSB-SC
plot(t,sc)
%
fprintf('Plotting DSB-SC in Figure No. 2\n')
figure(2)
lce = 1+cos(OMEGA_M*t);                % Generate envelope for DSB-LC
lc  = lce .* cos(OMEGA_C*t);           % DSB-LC
plot(t,lc,t,lce)
%
fprintf('Plotting DSB-SC in Figure No. 3\n')
figure(3)
beta = 1;
while beta >= 0
fm = cos(OMEGA_C*t + beta*sin(OMEGA_M*t)); % FM signal
plot(t,fm)
beta = input('Enter a value for beta: ');
end
