我一直收到一个错误提示:
Warning: Rank deficient, rank = 1, tol = 3.845925e-13.
In ed1 at 38
Warning from ed1 at 38
pf2(i)= length (find(sum((y)/(sqrt(NV))).^2)/(n<Tgam))/1000000;
要运行下面的代码,请在命令提示符中键入[y1,y2,y3,y4]= ed1(1,1,20,2);
。导致此错误的行是pf2(i)
和pd2(i)
function [y1,y2,y3,y4]= ed1(SNRL,SNRS,SNRH,n) %ed is the energy detection
g1= SNRL:SNRS:SNRH;
g=10.^(g1/10); %SNR
beta=0.8; % is the probability pfa, it cannot be more than 1
pf1=zeros(1,length(g));
pd1=zeros(1,length(g));
pf2=zeros(1,length(g));
pd2=zeros(1,length(g));
x=zeros(n,1000000);
y=zeros(n,1000000);
NV=zeros(n,1000000);
for a= 1:g %diff SNR
for b= 1:n %DIFF USERS,users are columns
NV(a,b)=1*b ;%assigning a value to the element of the matrix.
end
end
for i=1 : g %samples
for j=1:n %diff users.
%NV=ones(1000000,n);
x(j,:)=randn(1,1000000)*sqrt(NV(i,j));
y(j,:)=randn(1,1000000)*sqrt(g(i)/NV(i,j))+x(j,:);
end
%Tgam is the threshold of gamma distribution
Tgam = gaminv((1-beta),n/2,(2/n)*(1+(g(i)/NV(i,j)))); %probab of flase detection;
pf2(i)= length (find(sum((y)/(sqrt(NV))).^2)/(n<Tgam))/1000000;
pd2(i)= length (find(sum(x/sqrt(NV)).^2)/n<Tgam)/1000000;
y1=pf1; y2=pd1; y3=pf2; y4=pd2;
end
有什么建议是导致这个问题的原因?请问该如何解决?谢谢。
x
,没有最大可能的秩。换句话说,它有线性相关的行/列,而不应该有。为什么它很重要?因为你正在对x
使用mrdivide
操作符,它试图解决一个方程系统,但恰好是秩缺陷的。如何解决它?嗯,你需要调试代码并查看为什么会出现这种情况。 - Eitan T