% Create an array of 1000 time instants, in steps of 0.001 s.
time=[0:999]*0.001;
% Create a carrier signal at frequency f
f=12; % Hz 
% Create an in-phase carrier 
Icarrier=cos(2*pi*f*time);
% Create a quadrature carrier 
Qcarrier  = sin(2*pi*f*time);
% Create a modulating signal at frequency g
g=2; % Hz 
modulation=1+sin(2*pi*g*time);
% Modulation depth
m=1; % 100% modulation
% Multiply the modulation by the carrier
Isignal=m*modulation.*Icarrier;
Qsignal=m*modulation.*Qcarrier;
% Plot the carriers and modulating signal
subplot(2,1,1);
plot(time,Icarrier);
hold on;
plot(time,Qcarrier,'--k');
hold on;
plot(time,modulation,'-.r');
% Annotations
title('I, Q(--) and Modulating Signal (-.)');
ylabel('Amplitude (V)');
grid on;
% Plot the AM signals
subplot(2,1,2);
plot(time,Isignal);
hold on;
plot(time,Qsignal,'--k');
hold on;
% Plot the envelope
plot(time,modulation,':b');
% Annotations
title('I and Q (--) AM Signals and Envelope (:)');
xlabel('Time (s)');
ylabel('Amplitude (V)');
grid on;