Undefined operator '*' for input arguments of type 'matlab.ui.control.UIControl'.
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ba Ba Black Sheep!
el 29 de Sept. de 2017
Respondida: Walter Roberson
el 29 de Sept. de 2017
The following function is giving an error,
function tf = GUI_ListBoxAdd(vH, bUni, vStr, vID);
% Add an entry to a GUI list box.
%
% Sucess = GUI_ListBoxAdd(HandleTagName, Unique, String, Number)
% Sucess = GUI_ListBoxAdd([], Unique, String, Number)
%
% If Unique is 1 and String is already in the list, then this
% function will not add another copy of the item. If Number
% is not specified it will be set to the numerical value of
% the string, or 0. String can be a cell matrix containing
% a string list or a list box matrix. Number can be a vector
% containing numbers associated with a string list. A non-GUI
% list box matrix is a cell matrix that is not associated
% a GUI list box object.
%
% If HandleTagName is not specified (empty) then a non-GUI
% list box matrix will be created; call the GUI_ListBoxCopy()
% function to access it.
%
% Call the GUI_ListBoxClear() function when the list box is
% no longer required.
%
% See also GUI_GetID.
% Intialize for fail case!
tf = 0;
if isempty(vH)
sGlobal = 'GUI_ListBox';
else
hObj = GUI_GetID(vH);
if hObj == 0;
return;
end;
aaa = hObj * 1e7;
sGlobal = sprintf('GUI_ListBox_%012ld', Trunc(aaa));
end
try
vID = vID;
bSet = 1;
catch
vID = NaN;
bSet = 0;
dID = NaN;
end
% If a message box cell matrix is passed then
% set vID with the numeric part.
[iStrR iStrC] = size(vStr);
if iscell(vStr);
if iStrC > 1;
bSet = 1;
vID = zeros(1, iStrR);
for iSub = 1 : iStrR;
vID(iSub) = vStr{iSub, 2};
end;
end;
else;
vStr = {vStr};
end;
% If vID has been specified, it must have the same
% length (rows) as vStr.
iLenID = length(vID);
if bSet & (iStrR ~= iLenID)
return;
end
eval(sprintf('global %s;', sGlobal));
eval(sprintf('vTmp = %s;', sGlobal));
% If bUni is true then check for repeated values before adding
for iInSub = 1 : iStrR;
sStr = vStr{iInSub, 1};
if bSet;
dID = vID(iInSub);
end;
[iLen iNull] = size(vTmp);
if iLen < 1;
iSub = 1;
else;
if bUni == 1;
% If not found then add the unique value
if FindInStrList(sStr, vTmp(:, 1)) == 0;
iSub = iLen + 1;
else;
iSub = 0;
end;
else;
iSub = iLen + 1;
end;
end;
if iSub > 0;
vTmp{iSub, 1} = sStr;
if bSet;
vTmp{iSub, 2} = dID;
else;
vTmp{iSub, 2} = atof(sStr);
end;
tf = 1;
end;
end;
% Set the listbox with the new list
eval(sprintf('%s = vTmp;', sGlobal));
if ~isempty(vH);
%set(handles.listbox1, 'String', prev_str, 'Value', length(prev_str));
set(hObj, 'String', vTmp(:, 1),'Value', length(vTmp(:, 1)));
end;
Error
Undefined operator '*' for input arguments of type 'matlab.ui.control.UIControl'.
Error in GUI_ListBoxAdd (line 37)
aaa = hObj * 1e7;
Error in Scratch>pushDet_Callback (line 258)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Scratch (line 17)
gui_mainfcn(gui_State, varargin{:});
Error while evaluating UIControl Callback
0 comentarios
Respuesta aceptada
Walter Roberson
el 29 de Sept. de 2017
Change
aaa = hObj * 1e7;
to
aaa = double(hObj) * 1e7;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!