필터 지우기
필터 지우기

Undefined variable "numel" or class "numel"

조회 수: 1 (최근 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 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