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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by