Code:
H=50:50:100; % height
for zz=1:length(H)
flag=1;
while flag
for x=1:100
for y=1:100
cvx_begin
variable p_opt3(2*U,Omax)
expression E3(2)
% 计算re
for jre1=1:U
re2(jre1)=pow_pos((x-W48(jre1,1)),2)+pow_pos((y-W48(jre1,2)),2);
end
for jre2=U+1:U*2
re2(jre2)=pow_pos((x-W48(jre2,1)),2)+pow_pos((y-W48(jre2,2)),2);
end
re=re2';
% 求v
for l=1:L
E3(l)=c1*pow_pos(norm(v_opt3(l)),3)+c2*inv_pos(v_opt3(l));
end
g3=sum(E3(:));
M3=f3(48)-elta3(o)*g3; % M无限小
cvx_end
if abs(M3(o))>delta
o=o+1; % x=1时,如果y=1满足该条件,进入for循环y=2,直到满足M3<=delta,输出该x,y
else
qx(count,zz)=x;
qy(count,zz)=y;
count=count+1;
break;
end
end %y循环
end %x循环
flag=0;
end % while循环
end % H
figure(1)
grid on
H=50:50:100;
zz=1:length(H);
for cou=1:count
plot3(qx(count,zz),qy(count,zz),H(zz));
end
legend(‘Mixed pairing algorithm’,‘Location’,‘NorthEast’);
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
zlabel(‘Z (m)’);
hold on
The wrong is “Index at position 1 beyond array boundary (cannot exceed 100)” in “plot3(qx(count,zz),qy(count,zz),H(zz));”.
I think it is beacuse " for x=1:100 end " and " for y=1:100 end ". But I don’t know how to correct the wrong. It maybe not is a probelm of cvx, but I need to submit the figure tomorrow morning and nobody knows it around me. Please help me!