%% Quadrature Amplitude Modulation of Two Sinusoidal Signals
% Generate two sinusoidal signals frequencies of 10 Hz and 20 Hz, sampled at a rate of 200 Hz for 1 second. Embed the sinusoids in white Gaussian noise of variance 0.01.

fs = 200;
t = 0:1/fs:1;
i = sin(2*pi*10*t) + randn(size(t))/10;
q = sin(2*pi*20*t) + randn(size(t))/10;

%
% Create a quadrature amplitude modulated signal from signals i and q using a carrier frequency of 70 Hz. Compute the Welch power spectral density estimates of the original and modulated sequences. Use a 100-sample Hamming window with 80 samples of overlap. Specify an FFT length of 1024.

y = modulate(i,70,fs,'qam',q);

pwelch([i;q;y]',hamming(100),80,1024,fs,'centered') 
legend('In-phase signal','Quadrature signal','Modulated signal')

%
%
% Copyright 2018 The MathWorks, Inc.