%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% All rights reserved by Krishna Pillai, http://www.dsplog.com
% The file may not be re-distributed without explicit authorization
% from Krishna Pillai.
% Checked for proper operation with Octave Version 3.0.0
% Author : Krishna Pillai
% Email : krishna@dsplog.com
% Version : 1.0
% Date : 8th March 2009
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Script for showing the spectral plot in the presence of I-Q imbalance
clear
fsc = 0.625; % subcarrier frequency
fs = 20; % sampling frequency
fc = 2.5; % carrier frequency
N = 64; % fft order
t = [0:1/fs:3.2]; % time
t = t(1:end-1);
% iq imbalance parameters
phiDegree = 5; % phase imbalance in degrees
alpha = 0.25;% amplitude imbalance
% transmit signal
x = exp(j*2*pi*fsc*t);
% carrier signal
cNoIQ = exp(j*2*pi*fc*t); % without IQ imbalance
cWithIQ = cos(2*pi*fc*t) + j*(1+alpha)*sin(2*pi*fc*t + phiDegree*pi/180); % with IQ imbalance
% up-conversion
yNoIQ = real(x.*cNoIQ);
yWithIQ = real(x.*cWithIQ) ;
% downconversion
cRx = exp(-j*2*pi*fc*t);
xHatSC_NoIQ = (yNoIQ.*cRx);
xHatSC_WithIQ = (yWithIQ.*cRx);
% spectrum plots
xHatSC_NoIQ_F = fft(xHatSC_NoIQ,N)/N;
xHatSC_WithIQ_F = fft(xHatSC_WithIQ,N)/N;
close all
figure
plot([-N/2:N/2-1]*fs/N,(abs(fftshift(xHatSC_NoIQ_F))),'b', 'LineWidth', 2);
hold on
plot([-N/2:N/2-1]*fs/N,(abs(fftshift(xHatSC_WithIQ_F))),'m', 'LineWidth', 2);
legend( 'no IQ imbalance', 'with IQ imbalance');
axis([-2 2 0 1]) ;
xlabel('frequency, MHz');
ylabel('amplitude');
title('Spectrum of received signal - with/without transmit iq imbalance');
grid on