Hi there and thanks in advance for your help regarding my problem. I have a SDP which is convex and can be easily solved by CVX. However, I am receiving an strange error and I can not figure out where I am doing something wrong. To give a background on the problem, this is an SDP relaxation of the TDOA localization problem which is nonconvex in its original form. It is a well-known relaxation and well-known researchers such as Zhi-Quan Luo have proposed it earlier. I tried to simulate it but can not get passed this CVX error. The error is as follows:
??? Subscript indices must either be real positive integers or logicals.
Error in ==> cvx_extract at 344
tmpv = sum(dbcA(temp,:)~=0,2)==1;
Error in ==> cvx_solve at 26
[ At, cones, sgn, Q, P, exps, dualized ] = cvx_extract( shim.config, shim.name );
Error in ==> cvx_finish at 57
[ status, result, bound, iters, tol ] = cvx_solve;
Error in ==> cvx_end at 11
evalin( ‘caller’, ‘cvx_finish’ );
Error in ==> Centralized_test at 226
cvx_end
I checked this error and it seems that an index zero is somehow generated in temp which causes the error. Below, I have attached the code for this problem:
clear all
close all
clc
N=6;
Xmax=1;
sig_v=0.1;
dim=2;
xt=Xmax*rand([dim,1]);
x=Xmax*rand([dim,N-1]);
for i=1:N-1
r(i)=norm(x(:,i)-xt)-norm(xt)+sig_v*randn;
end
% Semi-Definite Relaxation of the NLS (Tom Luo Approach)
delta=10^(-5);
C=zeros(N-1,N);
for i=1:N-1
C(i,1)=1;
C(i,i+1)=-1;
end
clear X G
cvx_solver sedumi
cvx_begin SDP
variable z
variable X(dim,1)
variable g(N,1)
variable G(N,N) symmetric
GG=[G g; g' 1];
GGI=[1 g'; g G];
CC=[C'*C -C'*r'; -r*C r*r'];
XX=[eye(dim,dim) X; X' z];
xx=zeros(dim+1,1);
xx(:,1)=[zeros(dim,1); -1];
for i=2:N
xx(:,i)=[x(:,i-1); -1];
end
minimize trace(GG*CC)
subject to
GGI >= 0
XX >= 0
for i=1:N
g(i,1) >= 0;
end
G(1,1)==xx(:,1)'*XX*xx(:,1);
for i=1:N-1
G(i+1,i+1)==xx(:,i+1)'*XX*xx(:,i+1);
end
for i=1:N-1
G(i+1,1) >= xx(:,i+1)'*XX*xx(:,1);
G(i+1,1) >= -xx(:,i+1)'*XX*xx(:,1);
end
for i=1:N-1
for j=i+1:N-1
G(i+1,j+1) >= xx(:,i+1)'*XX*xx(:,j+1);
G(i+1,j+1) >= -xx(:,i+1)'*XX*xx(:,j+1);
end
end
cvx_end
cvx_status
yhat6=X;
error6=norm(xt-yhat6)^2