Undefined variable "numel" or class "numel"

1 次查看(过去 30 天)
Hie, how can i solve the above error in this code as below;
repelem = {};
for ii = 1:numel{subset}
subsetLabels{ii} = repelem{{subset{ii}.Description},subset{ii}.Count,1};
end
subsetLabels = vertcat(subsetLabels{:});
%nume1 = {};
togglefig('Sample Images',1)
[hpos,hdim] = distributeObjects(numel(subset),0.05,0.95,0.01);
[vpos,vdim] = distributeObjects(3,0.95,0.05,0.025);
ax = gobjects(numel(subset),1);
[hind,vind] = meshgrid(1:numel(imgSet),1:subset(1).Count);
for ii = 1:numel(subsetNames)
ax(ii) = axes('Units','Normalized',...
'Position',...
[hpos(hind(ii)) vpos(vind(ii)) hdim vdim]);
imshow(subsetNames{ii});
title(subsetLabels{ii},'fontsize',12)
end
expandAxes(ax);
  2 个评论
Gautam
Gautam 2020-6-16
for ii = 1:numel{subset} ------------------>>> change the bracket i.e numel(subset)
Talent Mukaro
Talent Mukaro 2020-6-16
thank you Sir. that error resolved. Here is another error;
repelem = {};
for ii = 1:numel(subset)
subsetLabels{ii} = repelem{{subset(ii).Description},subset(ii).Count,1};
end
subsetLabels = vertcat(subsetLabels{:});
The error is;
Matrix indices must be full double.
Error in SignLive (line 19)
subsetLabels{ii} = repelem{{subset(ii).Description},subset(ii).Count,1};

请先登录,再进行评论。

采纳的回答

madhan ravi
madhan ravi 2020-6-16
numel(subset)
  1 个评论
Talent Mukaro
Talent Mukaro 2020-6-16
thank you Sir. that error resolved. Here is another error;
repelem = {};
for ii = 1:numel(subset)
subsetLabels{ii} = repelem{{subset(ii).Description},subset(ii).Count,1};
end
subsetLabels = vertcat(subsetLabels{:});
The error is;
Matrix indices must be full double.
Error in SignLive (line 19)
subsetLabels{ii} = repelem{{subset(ii).Description},subset(ii).Count,1};

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2020-6-16
for ii = 1:numel{subset}
That requests that a variable named numel is indexed as a cell array, at offset subset
subsetLabels{ii} = repelem{{subset{ii}.Description},subset{ii}.Count,1};
That requests that a variable named repelem be indexed as a cell.
In MATLAB, the {} operators are used for creating cell arrays, and for indexing "inside" cell arrays, string objects, table objects, and a few other kinds of object.
ax = gobjects(numel(subset),1);
That requests that the numel function be executed on the content of the variable subset . That looks quite reasonable to do.
A function name with () after it indicates invoking a function.
An array with () after it indicates indexing into the array. This is the same () appearance as for functions being invoked, so they can be confused at first glance.
This line of code asks to invoke numel on subset, and then it takes the result of that and takes the constant 1, and uses them as parameters to invoke the gobjects function.
numel{subset}
Not likely to work. You probably do not have a variable named numel to index into. More likely is that you want to invoke numel function on subset, just like you did on constructing ax
  1 个评论
Talent Mukaro
Talent Mukaro 2020-6-16
thank you Sir. now this is the new error
Index exceeds matrix dimensions.
Error in SignLive (line 19)
subsetLabels(ii) = repelem((subset(ii).Description),subset(ii).Count,0);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by