Dear Matlab users,
I am running the code below:
function GSVD_fad
no_samples=1e3;
SNR_dB=-5:5:35;
SNR_linear=10.^(SNR_dB/10);
Cs=zeros(6,length(SNR_dB));
for Icase=1:6
if Icase==1, nt=2; nm=2; ne=2;
elseif Icase==2, nt=3; nm=2; ne=2;
elseif Icase==3, nt=4; nm=2; ne=5;
elseif Icase==4, nt=4; nm=5; ne=4;
elseif Icase==5, nt=4; nm=6; ne=7;
else nt=12; nm=6; ne=54;
end
for i=1:no_samples;
P=sym(zeros(nt,nt));
P1=zeros(nt,nt);
temp=0;
Hm = (1/sqrt(2))*(randn(nm,nt)+j*randn(nm,nt));
He = (1/sqrt(2))*(randn(ne,nt)+j*randn(ne,nt));
r=rank(He)
[U, V, A, C, D]=gsvd(Hm,He);
C1=(C.')*C;
D1=(D.')*D;
A1=(A')*A;
for l=1:nt
syms x
if (C1(l,l)>D1(l,l))
if (D1(l,l)==0)
D1(l,l)=0.00000001;
end
P(l,l)=P(l,l)+((-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(x*A1(l,l))))/(2*C1(l,l)*D1(l,l)));
end
end
for m=1:length(SNR_dB)
for l=1:nt
s=l+1;
if (s<=nt)
if(C1(l,l)>D1(l,l)||C1(s,s)>D1(s,s))
syms x
f=sum(diag(A1*P))-SNR_linear(m);
temp=vpa(solve(f==0,x));
end
end
end
for l=1:nt
if(C1(l,l)>D1(l,l))
y=((-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(temp*A1(l,l))))/(2*C1(l,l)*D1(l,l)));
if (y>0)
P1(l,l)=(-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(temp*A1(l,l))))/(2*C1(l,l)*D1(l,l));
else
P1(l,l)=0;
end
end
end
Cs(Icase,m)=Cs(Icase,m)+log2(real(det((eye(nt)+P1*C1))))-log2(real(det(eye(nt)+P1*D1)));
end
end
end
Cs=Cs/no_samples;
and in some cases I get this warning: system is rank deficient. solution is not unique. How can I deal with this?
Thank you in advance,
El
I am running the code below:
function GSVD_fad
no_samples=1e3;
SNR_dB=-5:5:35;
SNR_linear=10.^(SNR_dB/10);
Cs=zeros(6,length(SNR_dB));
for Icase=1:6
if Icase==1, nt=2; nm=2; ne=2;
elseif Icase==2, nt=3; nm=2; ne=2;
elseif Icase==3, nt=4; nm=2; ne=5;
elseif Icase==4, nt=4; nm=5; ne=4;
elseif Icase==5, nt=4; nm=6; ne=7;
else nt=12; nm=6; ne=54;
end
for i=1:no_samples;
P=sym(zeros(nt,nt));
P1=zeros(nt,nt);
temp=0;
Hm = (1/sqrt(2))*(randn(nm,nt)+j*randn(nm,nt));
He = (1/sqrt(2))*(randn(ne,nt)+j*randn(ne,nt));
r=rank(He)
[U, V, A, C, D]=gsvd(Hm,He);
C1=(C.')*C;
D1=(D.')*D;
A1=(A')*A;
for l=1:nt
syms x
if (C1(l,l)>D1(l,l))
if (D1(l,l)==0)
D1(l,l)=0.00000001;
end
P(l,l)=P(l,l)+((-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(x*A1(l,l))))/(2*C1(l,l)*D1(l,l)));
end
end
for m=1:length(SNR_dB)
for l=1:nt
s=l+1;
if (s<=nt)
if(C1(l,l)>D1(l,l)||C1(s,s)>D1(s,s))
syms x
f=sum(diag(A1*P))-SNR_linear(m);
temp=vpa(solve(f==0,x));
end
end
end
for l=1:nt
if(C1(l,l)>D1(l,l))
y=((-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(temp*A1(l,l))))/(2*C1(l,l)*D1(l,l)));
if (y>0)
P1(l,l)=(-1+sqrt(1-4*C1(l,l)*D1(l,l)+4*(C1(l,l)-D1(l,l))*C1(l,l)*D1(l,l)/(temp*A1(l,l))))/(2*C1(l,l)*D1(l,l));
else
P1(l,l)=0;
end
end
end
Cs(Icase,m)=Cs(Icase,m)+log2(real(det((eye(nt)+P1*C1))))-log2(real(det(eye(nt)+P1*D1)));
end
end
end
Cs=Cs/no_samples;
and in some cases I get this warning: system is rank deficient. solution is not unique. How can I deal with this?
Thank you in advance,
El