uint16 dimensions work in tiledlayout but not in nexttile

조회 수: 2 (최근 30일)
T. David
T. David 2022년 11월 14일
편집: Walter Roberson 2025년 5월 5일
Try running the following sequence of commands, which gets an error:
numXTiles = uint16(2);
numYTiles = uint16(1);
mainTile = numXTiles * numYTiles + 1;
mainYTiles = numYTiles * 2;
numYTiles = numYTiles + mainYTiles;
tiles = tiledlayout(numYTiles, numXTiles);
ax = nexttile(tiles, mainTile, [mainYTiles numXTiles]);
Then try this sequence, which doesn't get an error:
numXTiles = 2;
numYTiles = 1;
mainTile = numXTiles * numYTiles + 1;
mainYTiles = numYTiles * 2;
numYTiles = numYTiles + mainYTiles;
tiles = tiledlayout(numYTiles, numXTiles);
ax = nexttile(tiles, mainTile, [mainYTiles numXTiles]);
The documentation for nexttile says that the tilelocation and span "are positive whole numbers".
I get this error when using uint16:
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in nexttile
Error in nexttile
  댓글 수: 3
Bruno Luong
Bruno Luong 2022년 11월 14일
I agree, it looks like a bug. But workaround is easy (cast to input double)
Harshit Gupta
Harshit Gupta 2022년 11월 18일
I work at MathWorks and have forwarded this feedback to the relevant team.

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

답변 (1개)

Rahul
Rahul 2025년 5월 5일
The error looks like a bug. I was able to reproduce the error in MATLAB R2022a.
I observed that this has been resolved from MATLAB R2023b onwards. You can consider uprading to a more recent version to resolve this issue.
Thanks.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by