Undefined variable "numel" or class "numel"

2 ビュー (過去 30 日間)
Talent Mukaro
Talent Mukaro 2020 年 6 月 16 日
コメント済み: Talent Mukaro 2020 年 6 月 16 日
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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by