In an assignment A(I) = B, the number of elements in B and I must be the same.

2 views (last 30 days)
Hi please i need a help because when i run my code i have this error: In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in UAQP_power_control_method (line 67) SINR11(j)=findRangeSINR(handles); The code is: {function [Pmacro Pfemto] = UAQP_power_control_method(handles) Pmacro_dbm = str2double(get(handles.edit1,'String')); Pmacro = (10.^(Pmacro_dbm / 10)) / 1000; Pfemto_max_dbm = str2double(get(handles.edit2,'String')); Pfemto_max = (10.^(Pfemto_max_dbm / 10)) / 1000; Pfemto_def_dbm = str2double(get(handles.edit4,'String')); Pfemto_def = (10.^(Pfemto_def_dbm / 10)) / 1000; target_SINR = str2double(get(handles.edit5,'String')); coordVectors = get(handles.figure1, 'UserData'); %numOfFemtocells = min(size(coordVectors.femt_x, 2), size(coordVectors.femt_y, 2)); numOfFemtocells = str2num(get(handles.edit20,'String')); Pfemto_init = ones(1, numOfFemtocells)*Pfemto_def; pow_default = str2num(get(handles.edit13,'String')); coordVectors.powFemto = (ones(1, numOfFemtocells))*(10^(pow_default / 10)) / 1000; Pfemto_last = coordVectors.powFemto; Pfemto=zeros(1,numOfFemtocells); N21 = str2double(get(handles.edit15,'String')); N31 = str2double(get(handles.edit35,'String')); N1=str2num(get(handles.edit47,'String')); N2=str2num(get(handles.edit18,'String')); N3=str2num(get(handles.edit19,'String')); coordVectors = get(handles.figure1, 'UserData'); %numOfFemtocells = str2num(get(handles.edit20,'String')); %numOfFemtocells = handles.edit20; numOfFemtousers = handles.edit11; numOfMacrocells = 1; P0=10; o2=0.4; o1=0.9; o3=0.1; Q21=0.7; Q31=0.3; Q22=0.6; Q32=0.2; D=0.7; Pfemto = zeros(1,numOfFemtocells); a = o2*Q21*ones(N2,1); b = o2*Q22*ones(N2,1 ); c = o2*Q31*ones(N3,1 ); d = o2*Q32*ones(N3,1); SINR1=0; SINR2=0; SINR3=0; R = str2num(get(handles.edit11,'String')); currentSINR=zeros(1,numOfFemtocells); target_SINR = str2double(get(handles.edit5,'String')); coordVectors = get(handles.figure1, 'UserData'); P1=Pfemto; P2=P0+(N1*o1)+sum(a(1:N2))+(sum(c(1:N3))*D); SINRp11=zeros(1,N1); SINRp12=zeros(1,N1); SINRp21=zeros(1,N2); SINRp22=zeros(1,N2); SINRp31=zeros(1,N3); SINRp32=zeros(1,N3); SINR11=zeros(1,N1); SINR12=zeros(1,N1); SINR21=zeros(1,N2); SINR22=zeros(1,N2); SINR31=zeros(1,N3); SINR32=zeros(1,N3);
for j=1:N1 if (Pfemto == P1) %coordVectors.powFemto = P1; %set(handles.figure1, 'UserData', coordVectors); SINR11(j)=findRangeSINR(handles); else %coordVectors.powFemto = P2; %set(handles.figure1, 'UserData', coordVectors); SINR12(j) = findRangeSINR(handles); end end SINRp11=sum( SINR11(j)/N1); SINRp12=sum(SINR12(j)/N1); for k=1:N2 if (Pfemto == P1); %set(handles.figure1, 'UserData', coordVectors); SINR21(k)=findRangeSINR(handles); else %coordVectors.powFemto = P2; % set(handles.figure1, 'UserData', coordVectors); SINR22(k) = findRangeSINR(handles); end end SINRp21=sum(SINR21(k)/N2); SINRp22=sum(SINR22(k)/N2); for l=1:N3 if (Pfemto == P1) %set(handles.figure1, 'UserData', coordVectors); SINR31(l)=findRangeSINR(handles); else %set(handles.figure1, 'UserData', coordVectors); SINR32(l) = findRangeSINR(handles); end end SINRp31=sum(SINR31(l)/N3); SINRp32=sum(SINR32(l)/N3); for i=1:numOfFemtocells if (SINRp11> SINRp12 && SINRp21> SINRp22&& SINRp31> SINRp32) Pfemto=P2; else if (SINRp11> SINRp12 && SINRp21> SINRp22); Pfemto(i)=P0+(N1*o1)+sum(a(1:N2))*D; else if (SINRp11> SINRp12) Pfemto(i)=P0+(N1*o1)+sum(a(1:N21))*D; else Pfemto=P1; end end end end end } Thenks.
  1 Comment
Jan
Jan on 14 Apr 2018
Seriously? Don't you see, that the code is unreadable? Did you see, that the code of other questions looks much better? And did you ask yourself, how to make your code readable?
Please read Tutorial: How to format code. Add a copy of the complete error message, such that the readers have a hint, in which line the error occurs. Guessing this detail is less efficient.

Sign in to comment.

Answers (0)

Categories

Find more on Physics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!