clear; clc; close all; K=3; % nonlinearity order M=1; % number of memory taps N=(K+1)/2; % the effective nonlinearity terms A = sym('a', [N M],'real'); % PA cofficients D = sym('d', [N M],'real'); % DPD cofficients U = flip(sym('u', [2*M-1 1],'real')); % the index indicate the time index V = flip(sym('v', [2*M-1 1],'real')); % the index indicate the time index dpd_coeff=zeros(N,M);% DPD coefficient dpd_coeff(1,1)=1;% DPD coefficient c=dpd_coeff; Iteration_Number=2; mu = sym('mu','positive'); for rrr=1:1 for m=1:M for r=1:N B(r,:)=abs(conj((U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))')).^(2*r-2); end w(1,m)=expand(sum(B.*c*(U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))));% DPD output equation %for xtelda[n]:xtelda[n-(M-1)] (number of memory depth) end %% construct X matrix for r=1:N X(1,(M*(r-1)+1):r*M)=w.*((abs(w)).^(2*(r-1))); % DPD output equation adding nonlinearity terms end %% construct Xtelda matrix for m=1:M for r=1:N B(r,:)=abs(conj((U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))')).^(2*r-2); end w(1,m)=expand(sum(B.*D*(U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))));% DPD output equation %for xtelda[n]:xtelda[n-(M-1)] (number of memory depth) end %% construct Xtelda matrix for r=1:N XTelda(1,(M*(r-1)+1):r*M)=w.*((abs(w)).^(2*(r-1))); % DPD output equation adding nonlinearity terms end %% construct Y matrix for r=1:N PAcoeff(1,(1+(r-1)*M):r*M)=A(r,:); end y=XTelda*PAcoeff'; U2 = flip(sym('u', [3*M-2 1],'real')); % the index indicate the time index V2 = flip(sym('v', [3*M-2 1],'real')); % the index indicate the time index for s=1:N Xmemory(1,M*(s-1)+1:s*M)=X(1,M*(s-1)+1:s*M); XTeldamemory(1,M*(s-1)+1:s*M)=XTelda(1,M*(s-1)+1:s*M); for r=1:length(U) Xmemory(1,M*(s-1)+1:s*M)=subs(Xmemory(1,M*(s-1)+1:s*M),U(r),U2(r)); Xmemory(1,M*(s-1)+1:s*M)=subs(Xmemory(1,M*(s-1)+1:s*M),V(r),V2(r)); XTeldamemory(1,M*(s-1)+1:s*M)=subs(XTeldamemory(1,M*(s-1)+1:s*M),U(r),U2(r)); XTeldamemory(1,M*(s-1)+1:s*M)=subs(XTeldamemory(1,M*(s-1)+1:s*M),V(r),V2(r)); end end for s=1:M ymemory(1,s)=y; for r=1:length(U) ymemory(1,s)=subs(ymemory(1,s),U(r),U2(r+(s-1))); ymemory(1,s)=subs(ymemory(1,s),V(r),V2(r+(s-1))); end end %% construct Y matrix for r=1:N ymatrix(1,(M*(r-1)+1):r*M)=ymemory.*((abs(ymemory)).^(2*(r-1))); end for r=1:N DPDcoeff(1,(1+(r-1)*M):r*M)=D(r,:); end Y=ymatrix; yy=expand(Y'*Y);% (Y^H)*Y yx=expand(Y'*XTeldamemory(1,1));% (Y^H)*X yHx=expand(Y'*Xmemory);% (Y^H)*X YY=expand(rewrite(yy,'sqrt')); YX=expand(rewrite(yx,'sqrt')); rrr %% taking the mathematical expectation using equation (60) % substitute by E(u^odd)=E(v^odd)=0 S = sym('S','positive'); YYsub = YY; YXsub = YX; for g=1:N*M for h=1:N*M for t=1:4*K for r=1:length(U2) YYsub(g,h)=subs(YYsub(g,h),U2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); YYsub(g,h)=subs(YYsub(g,h),V2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); end end end end for g=1:N*M for h=1:N*M for t=1:4*K for r=1:length(U2) YYsub(g,h)=subs(YYsub(g,h),U2(r)^(2*t-1),0); YYsub(g,h)=subs(YYsub(g,h),V2(r)^(2*t-1),0); end end end end for g=1:N*M for t=1:4*K for r=1:length(U) YXsub(g,1)=subs(YXsub(g,1),U(r)^(2*t),prod(1:2:2*t)*S^(2*t)); YXsub(g,1)=subs(YXsub(g,1),V(r)^(2*t),prod(1:2:2*t)*S^(2*t)); end end end for g=1:N*M for t=1:4*K for r=1:length(U) YXsub(g,1)=subs(YXsub(g,1),U(r)^(2*t-1),0); YXsub(g,1)=subs(YXsub(g,1),V(r)^(2*t-1),0); end end end for r=1:N*M YYsub=subs(YYsub,DPDcoeff(r),dpd_coeff(r)); YXsub=subs(YXsub,DPDcoeff(r),dpd_coeff(r)); end %% DPD coefficients mathimatical relationships rrr dpd_coeff=YYsub\YXsub; DPD(:,rrr)=dpd_coeff; end for rrr=1:Iteration_Number-1 for m=1:M for r=1:N B(r,:)=abs(conj((U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))')).^(2*r-2); end w(1,m)=expand(sum(B.*c*(U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))));% DPD output equation %for xtelda[n]:xtelda[n-(M-1)] (number of memory depth) end %% construct X matrix for r=1:N X(1,(M*(r-1)+1):r*M)=w.*((abs(w)).^(2*(r-1))); % DPD output equation adding nonlinearity terms end %% construct Xtelda matrix for m=1:M for r=1:N B(r,:)=abs(conj((U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))')).^(2*r-2); end w(1,m)=expand(sum(B.*D*(U(1+(m-1):(end+(m-1)-(M-1)))+1i*V(1+(m-1):(end+(m-1)-(M-1))))));% DPD output equation %for xtelda[n]:xtelda[n-(M-1)] (number of memory depth) end %% construct Xtelda matrix for r=1:N XTelda(1,(M*(r-1)+1):r*M)=w.*((abs(w)).^(2*(r-1))); % DPD output equation adding nonlinearity terms end %% construct Y matrix for r=1:N PAcoeff(1,(1+(r-1)*M):r*M)=A(r,:); end y=XTelda*PAcoeff'; U2 = flip(sym('u', [3*M-2 1],'real')); % the index indicate the time index V2 = flip(sym('v', [3*M-2 1],'real')); % the index indicate the time index for s=1:N Xmemory(1,M*(s-1)+1:s*M)=X(1,M*(s-1)+1:s*M); XTeldamemory(1,M*(s-1)+1:s*M)=XTelda(1,M*(s-1)+1:s*M); for r=1:length(U) Xmemory(1,M*(s-1)+1:s*M)=subs(Xmemory(1,M*(s-1)+1:s*M),U(r),U2(r)); Xmemory(1,M*(s-1)+1:s*M)=subs(Xmemory(1,M*(s-1)+1:s*M),V(r),V2(r)); XTeldamemory(1,M*(s-1)+1:s*M)=subs(XTeldamemory(1,M*(s-1)+1:s*M),U(r),U2(r)); XTeldamemory(1,M*(s-1)+1:s*M)=subs(XTeldamemory(1,M*(s-1)+1:s*M),V(r),V2(r)); end end for s=1:M ymemory(1,s)=y; for r=1:length(U) ymemory(1,s)=subs(ymemory(1,s),U(r),U2(r+(s-1))); ymemory(1,s)=subs(ymemory(1,s),V(r),V2(r+(s-1))); end end %% construct Y matrix for r=1:N ymatrix(1,(M*(r-1)+1):r*M)=ymemory.*((abs(ymemory)).^(2*(r-1))); end for r=1:N DPDcoeff(1,(1+(r-1)*M):r*M)=D(r,:); end Y=ymatrix; yy=expand(Y'*Y);% (Y^H)*Y yx=expand(Y'*XTeldamemory(1,1));% (Y^H)*X yHx=expand(Y'*Xmemory);% (Y^H)*X YY=expand(rewrite(yy,'sqrt')); YX=expand(rewrite(yx,'sqrt')); YHX=expand(rewrite(yHx,'sqrt')); rrr %% taking the mathematical expectation using equation (60) % substitute by E(u^odd)=E(v^odd)=0 YYsub = YY; YHXsub = YHX; for g=1:N*M for h=1:N*M for t=1:4*K for r=1:length(U2) YYsub(g,h)=subs(YYsub(g,h),U2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); YYsub(g,h)=subs(YYsub(g,h),V2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); YHXsub(g,h)=subs(YHXsub(g,h),U2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); YHXsub(g,h)=subs(YHXsub(g,h),V2(r)^(2*t),prod(1:2:2*t)*S^(2*t)); end end end end for g=1:N*M for h=1:N*M for t=1:4*K for r=1:length(U2) YYsub(g,h)=subs(YYsub(g,h),U2(r)^(2*t-1),0); YYsub(g,h)=subs(YYsub(g,h),V2(r)^(2*t-1),0); YHXsub(g,h)=subs(YHXsub(g,h),U2(r)^(2*t-1),0); YHXsub(g,h)=subs(YHXsub(g,h),V2(r)^(2*t-1),0); end end end end delta_dpd=(eye(N*M)-YYsub\YHXsub)*dpd_coeff; for r=1:N*M delta_dpd=subs(delta_dpd,DPDcoeff(r),dpd_coeff(r)); end DPD(:,rrr+1)=DPD(:,rrr)+mu*delta_dpd; dpd_coeff=DPD(:,rrr+1); end DPD