Figure size changes randomly

조회 수: 4 (최근 30일)
J. van Delft
J. van Delft 2015년 4월 2일
댓글: J. van Delft 2015년 4월 2일
I've recently started using Matlab R2014B for Linux (on Ubuntu 14.04). Previously I used R2014B on Windows 7. Some code does not work after the switch and I've tracked the problem down to an issue with the size of figures changing randomly:
close all; clear all;
hFig = figure('Color','White');
set(hFig, 'Position', [400 100 560 700])
f = getframe(gcf);
% Get figure size
pos = get(gcf, 'Position')
The problem is that the created figure has a size that is not equal to the specified size. For example it could be
pos =
395 95 570 702
But it changes every time I run the code.
Any ideas on this?
EDIT I noticed that the figure is not exactly at the same position I run the code, which explains the wrong position info but what is the cause behind this and how to remedy it?

채택된 답변

Jan
Jan 2015년 4월 2일
Did you try to insert a drawnow before getframe? Sometimes pause(0.02) allows the Java objects to be updated also.
  댓글 수: 1
J. van Delft
J. van Delft 2015년 4월 2일
A drawnow and a pause(0.1) between figure and set(...) seem to do the trick. So this is an issue with Java?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by