Error using subplot (line 301) Index exceeds number of subplots.

조회 수: 4 (최근 30일)
farhat khan
farhat khan 2019년 7월 24일
답변: Walter Roberson 2019년 7월 24일
ax = gobjects(imageset.Count,1);
for ii = 1:imageset.Count
ax(ii) = ...
subplot(floor(sqrt(imageset.Count)),ceil(sqrt(imageset.Count)),ii); %Error show me on this line
[~,currName] = fileparts(imageset.ImageLocation{ii});
imshow(read(imageset,ii))
title([num2str(ii),') ' currName],...
'interpreter','none','fontsize',7)
end
expandAxes(ax);
  댓글 수: 1
Star Strider
Star Strider 2019년 7월 24일
The error message is straightforward.
Your ‘ii’ index is greater than floor(sqrt(imageset.Count)) * ceil(sqrt(imageset.Count)).

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 7월 24일
>> t = 1:100;
>> find(floor(sqrt(t)).*ceil(sqrt(t)) < t)
ans =
Columns 1 through 25
3 7 8 13 14 15 21 22 23 24 31 32 33 34 35 43 44 45 46 47 48 57 58 59 60
Columns 26 through 45
61 62 63 73 74 75 76 77 78 79 80 91 92 93 94 95 96 97 98 99
For example, suppose the Count is 8, then sqrt(8) is between 2 and 3, so the floor() is 2 and ceil() is 3, and 2*3 = 6, which is less than 8, so when you tried to plot for the 7th you would run out of subplots.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by