Undefined operator '/' for input arguments of type 'matlab.ui​.control.U​IControl'.

2 次查看(过去 30 天)
Hello, Please i have this error whene i run my interface matlab:
Undefined operator '/' for input arguments of type 'matlab.ui.control.UIControl'.
Error in UAQP_power_control_method (line 63)
SINR2=target_SINR/currentSINR;
The code of my function is:
function [Pmacro Pfemto] = UAQP_power_control_method(handles)
Pmacro_dbm=handles.edit1;
%Pmacro_dbm = str2num(get(handles.edit1,'String'));
%Pmacro = (10^(Pmacro_dbm / 10)) / 1000;
Pfemto_max_dbm=handles.edit2;
%Pfemto_max_dbm = str2num(get(handles.edit2,'String'));
%Pfemto_max = (10^(Pfemto_max_dbm / 10)) / 1000;
%Pfemto_def_dbm = str2num(get(handles.edit4,'String'));
Pfemto_def_dbm=handles.edit4;
%Pfemto_def = (10^(Pfemto_def_dbm / 10)) / 1000;
target_SINR =handles.edit5;
%target_SINR = str2double(get(handles.edit5,'String'));
% N21=handles.edit15;
% N31=handles.edit35;
% N1=handles.edit47;
% N2=handles.edit18;
% N3=handles.edit19;
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;
%N1=2;
% numOfFemtousers = str2num(get(handles.edit11,'String'));
P_min=-10;
SINR_th=10;
% N1=round(rand*8);
% N2=round(rand*8);
% N3=round(rand*8);
P0=0.0;
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;
% b=o2*Q22;
% c=o2*Q31;
% d=o2*Q32;
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;
%for i=1:numOfFemtocells
for i=1:N1
currentSINR = findRangeSINR(handles);
SINR1=currentSINR;
end
for i=1:N2
currentSINR = findRangeSINR(handles);
SINR2=target_SINR/currentSINR;
end
for i=1:N3
currentSINR = findRangeSINR(handles);
SINR3=target_SINR/currentSINR;
end
SINRp1=SINR1;
SINRp2=SINR2;
SINRp3=SINR3;
for i=1:numOfFemtocells
if (SINRp1(i+1)> SINR(i) && SINRp2(i+1)> SINR(i)&& SINRp3(i+1)> SINR(i))
Pfemto(i)=P0+(N1*o1)+sum(a(1:N2))+(sum(c(1:N3))*D);
else if (SINRp1(i)> SINR(i) && SINRp2(i+1)> SINR(i))
Pfemto(i)=P0+(N1*o1)+sum(a(1:N2))*D;
else if(SINRp1(i+1)> SINR(i))
Pfemto(i)=P0+(N1*o1)+sum(a(1:N21))*D;
else
Pfemto(i)=Pfemto(i-1);
end
end
end
end
end

采纳的回答

Walter Roberson
Walter Roberson 2018-4-11
You have
target_SINR =handles.edit5;
so target_SINR is a handle, not the content stored at the handle.
You have
SINR2=target_SINR/currentSINR;
so you are trying to divide the handle by something.
We cannot tell what the something is:
currentSINR = findRangeSINR(handles);
does not tell us what findRangeSINR does, and the code for that function was not included.
If you want the number the user has entered in the edit5 handle then you need
target_SINR = str2double(handles.edit5.String);
Caution: this will not update as the user enters new values: it will only update when the line is re-executed.
Note that you have three loops with the general form
for i=1:N1
currentSINR = findRangeSINR(handles);
SINR1=currentSINR;
end
Unless findRangeSINR is keeping a counter or choosing information randomly, then the output of that loop is not affected by how many times you run the loop body, since you do not use i anywhere in the loop, and you completely overwrite all of SINR1 each iteration of the loop. It is not obvious why you do not just do the assignments once without a for loop.
  6 个评论
brahmi ibtissem
brahmi ibtissem 2018-4-14
编辑:Walter Roberson 2018-4-14
Thanks. I modifie my code, No errors but i still have a problem. When i simulate i have SINR: -lnf dB( false value). how can i solve this problem.
This is my code:
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=0;
SINRp12=0;
SINRp21=0;
SINRp22=0;
SINRp31=0;
SINRp32=0;
SINR11=0;
SINR12=0;
SINR21=0;
SINR22=0;
SINR31=0;
SINR32=0;
for i=1:numOfFemtocells
for j=1:N1
coordVectors.powFemto = P1;
set(handles.figure1, 'UserData', coordVectors);
SINR11=findRangeSINR(handles);
coordVectors.powFemto = P2;
set(handles.figure1, 'UserData', coordVectors);
SINR21 = findRangeSINR(handles);
end
SINRp11=sum( SINR11/N1);
SINRp12=sum(SINR21/N1);
for k=1:N2
coordVectors.powFemto = P1;
set(handles.figure1, 'UserData', coordVectors);
SINR21=findRangeSINR(handles);
coordVectors.powFemto = P2;
set(handles.figure1, 'UserData', coordVectors);
SINR22 = findRangeSINR(handles);
end
SINRp21=sum(SINR21/N2);
SINRp22=sum(SINR22/N2);
for l=1:N3
coordVectors.powFemto = P1;
set(handles.figure1, 'UserData', coordVectors);
SINR1=findRangeSINR(handles);
coordVectors.powFemto = P2;
set(handles.figure1, 'UserData', coordVectors);
SINR2 = findRangeSINR(handles);
end
SINRp31=sum(SINR1/N3);
SINRp32=sum(SINR2/N3);
end
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
Walter Roberson
Walter Roberson 2018-4-14
If your findRangeSINR needs to look at the handles each time and you are sending it new data by setting the UserData field, then why not just pass it the data directly instead of going through the handles structure?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Object Containers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by