When arranging figures using gcf, Java Heap Space Error

I am trying to nicely arrange some figures on my screen in an array. I used the following, relatively poor code to try to assign each figure to a spot on the screen, but whenever I run it I get a Java Heap Space Overload error that stalls MatLab and forces me to quit:
screen = get(0, 'screensize');
%declare how many graphs wanted on screen
graphsWide = 4;
graphsTall = 3;
graphPos = screen * diag([0 (screen(4)*(graphsTall-1))/graphsTall...
screen(3)/graphsWide screen(4)/graphsTall]);
shiftRight = [graphPos(3), 0, 0, 0];
shiftDown = [0, graphPos(4), 0, 0];
graphIndex = @(i, j) (graphPos+((i-1)*shiftRight)+((j-1)*shiftDown));
for i = 1:12
figure(i);
set(gcf, 'position', graphIndex(i mod 4, floor(i/4));
end
Any ideas as to where I am going horribly wrong?

 채택된 답변

Amy Haskins
Amy Haskins 2014년 5월 23일
I'm not sure exactly where you went wrong, but a much easier solution to laying out figure windows in a nice grid is to dock them and then use the tile option in the Window menu. You can un-dock the figures panel from the editor but still have all the figures docked in the panel.
f = figure('WindowStyle','docked') % Create a new docked figure
set(gcf,'WindowStyle','docked') % Dock an existing figure

댓글 수: 1

Just what I wanted and it's built in. Thanks so much for showing me that. As for the code… I wish I knew what was wrong but I'll live with a workable solution.

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

추가 답변 (1개)

Jan
Jan 2014년 5월 23일

0 개 추천

Is the problem reproducible? Did you restart Matlab and the computer already? Did you install a new Java version and work e.g. on a Mac? When did this problem start to happen? Did Matlab work correctly before? Did you try to re-install Matlab?

카테고리

도움말 센터File Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품

태그

질문:

2014년 5월 23일

댓글:

2014년 5월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by