43 lines
1.3 KiB
Matlab
43 lines
1.3 KiB
Matlab
clc;
|
|
clear all;
|
|
close all;
|
|
%%
|
|
fsc = 1.0e5; % signal frequency
|
|
fs = 2.0e6; % sampling frequency
|
|
fc = 1.0e10; % carrier frequency
|
|
t = [0:1/fs:0.01]; % time
|
|
|
|
% IQ imbalance parameters
|
|
phiDegree = 10; % phase imbalance in degrees
|
|
alpha = 1.3;% amplitude imbalance
|
|
avg=1;
|
|
k=1;
|
|
|
|
I_before_correction = cos(2*pi*fc*t)+avg;
|
|
Q_before_correction = (1+alpha)*cos(2*pi*fc*t+phiDegree*pi/180) +k;
|
|
signal_IQ_before = I_before_correction+Q_before_correction*1j;
|
|
|
|
figure(1);
|
|
pwelch(signal_IQ_before, [],[],[],fs);
|
|
title('Spectrum at Rx baseband after I/Q correction');
|
|
%求均值
|
|
I_before_correction =I_before_correction-mean(I_before_correction);
|
|
Q_before_correction=Q_before_correction -mean(Q_before_correction);
|
|
|
|
%估计参数
|
|
e = sqrt(mean(Q_before_correction.*Q_before_correction)/mean(I_before_correction.*I_before_correction))-1;
|
|
phi = -asin(mean(I_before_correction.*Q_before_correction)/sqrt(mean(I_before_correction.*I_before_correction)*mean(Q_before_correction.*Q_before_correction)));
|
|
%P矩阵求解
|
|
P = [1,0;tan(phi),1/((1+e)*cos(phi))];
|
|
|
|
%计算IQ
|
|
IQ = P*[I_before_correction;Q_before_correction];
|
|
|
|
%重组信号
|
|
I =IQ(1,:);
|
|
Q =IQ(2,:);
|
|
signal_IQ = Q+I*1j;
|
|
%图形绘制
|
|
figure();
|
|
pwelch(signal_IQ, [],[],[],fs);title('Spectrum at Rx baseband after I/Q correction');
|
|
|