Info

This question is closed. Reopen it to edit or answer.

Why will window show me "Improper assignment with rectangular empty matrix" sometimes?

1 view (last 30 days)
Why will window show me "Improper assignment with rectangular empty matrix" sometimes?
It seems this error should tell me ,there is an error or bug in your code,so i can't run this code correctly,i will stop at the some or one of that error lines,if my thinking is correct,why will the code can give me the result sometimes? i mean,it can run the code correcly sometimes,but sometimes,it will stop running because of that error.
Why?i have no ideal why is this happend,here is my code below,and i use cvx ,you have to install the cvx first or you can't run the code below,and because using the cvx in the matlab,i can just declare variable
cvx begin ,FNNK_lowr(N,N,K) semidefinite , cvx end ,subject to ,etc instructions
hat_p_lowr=0.0315
bd=300
bdc=101
AXX3=zeros(1,bd);
lkk=1:bdc%lkk=1, 2, 3, 4
lkkspace=zeros(1,bdc)
rho_k=0:0.01:1
for lkk=1:bdc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for dd=1:bd
%OP4
%declare
K=4;
N=4;
L=5;%distance between RX & TX
xi=10^-4%tolerence between
nois_var_hk_2pow=0.1*(L^(-2.5))*10;%W,0.1*(L^(-2.5)),if this unit is dbm
nois_var_ak_2pow=[1.0000e-10 1.0000e-10 1.0000e-10 1.0000e-10 ];
nois_var_dk_2pow=[1.0000e-08 1.0000e-08 1.0000e-08 1.0000e-08 ];
bar_r=[10 10 10 10];
P_T=10
%channel build
h_1=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
h_2=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
h_3=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
h_4=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
h_kk=cat(2,h_1 ,h_2 ,h_3, h_4)
for n=1:4
h_k{n}=h_kk(1:4 , n);
n=n+1;
end
%==========================
cvx_begin
variable FNNK_lowr(N,N,K) semidefinite;%c7
%==========================
Fkk_lowr=cat(2,FNNK_lowr);
lowr=0
for o_lowr=1:4
Fk_lowr{o_lowr}=Fkk_lowr(1:4,o_lowr+3*lowr:4*o_lowr)
lowr=lowr+1;
end
tr_ace_lowr=0
for t=1:K
tr_ace_lowr=tr_ace_lowr+trace(Fk_lowr{t})
end
%====================================
%object function
minimize( tr_ace_lowr )
%====================================
%Constraint
subject to
%===================================================
%c5
c5_left_hand_lowr = 0;
for k = 1:K
sum_5_lowr = 0;
for j = 1:K
if j ~= k
sum_5_lowr = sum_5_lowr + h_k{k}' * Fk_lowr{j} * h_k{k};
end
end
c5_left_hand_lowr = c5_left_hand_lowr - sum_5_lowr+ (h_k{k}' * Fk_lowr{k} * h_k{k}*inv_pos(bar_r(1)))
c5_right_hand_lowr= nois_var_ak_2pow(1)*rho_k(lkk)+ nois_var_dk_2pow(1)
real( c5_left_hand_lowr ) *rho_k(lkk) >= c5_right_hand_lowr
end
%===================================================
%c10
c10_left_hand_lowr = 0;
sum_10_lowr = 0;
for j = 1:K
sum_10_lowr= sum_10_lowr + h_k{k}' * Fk_lowr{j} * h_k{k};
end
c10_left_hand_lowr =real(c10_left_hand_lowr + sum_10_lowr+nois_var_ak_2pow(1))*(1-rho_k(lkk))
c10_right_hand_lowr=hat_p_lowr
c10_left_hand_lowr>= c10_right_hand_lowr
cvx_end
c3(dd)=AXX3(dd)+cvx_optval;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
allthings=c3
c3_noninf=allthings(~isinf(allthings))
meann=min(c3_noninf)
[minvalue, n] = min(c3_noninf)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
us(lkk)=lkkspace(lkk)+minvalue
end
allthings_compare=us
min_samepower_diff_rho_F=min(us)
P_Tp=min_samepower_diff_rho_F
And the error, "Improper assignment with rectangular empty matrix" , always happen in this line
us(lkk)=lkkspace(lkk)+minvalue
If this error are shown in the window,all elements in FNNK_lowr are NaN,and i am confused in here too,the FNNK_lowr are the variable i declare,why are the elements be "NaN" ?

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!