The minimum size should be constant but I have been unable to achieve this. I read some stuff but nothing seems to work properlly. Any help would be apreciated.

답변 (3개)

Kelly Kearney
Kelly Kearney 2015년 12월 17일

1 개 추천

If you're using a recent version of Matlab, you can accomplish this via the SizeChangedFcn of the figure:
h = figure;
figszfun = @(~,~) set(h, 'position', max([0 0 200 200], h.Position));
h.SizeChangedFcn = figszfun;
In this example, the figure will be always be at least 200 x 200 pixels.
For older versions (pre-2014b), the same thing can be accomplished via the ResizeFcn.

댓글 수: 3

Jan
Jan 2015년 12월 18일
편집: Jan 2015년 12월 18일
If this works, why doesn't it cause an infinite recursion? Changing the figure size inside the function called after resizing a figure...
Armindo
Armindo 2015년 12월 18일
편집: Armindo 2015년 12월 18일
Hi thank you for the help but this dont work properlly. Image is always flickering
Kelly Kearney
Kelly Kearney 2015년 12월 18일
Hmm, good question, Jan, but recursion doesn't seem to be a problem, at least not on my system. I do get the flicker effect if I manually resize the figure smaller than the limit, since the mouse-set size and resize function are fighting each other, but that stops as soon as I release the mouse click.
Perhaps that's the difference between ResizeFcn and the newer SizeChangedFcn? I really haven't looked into it much.

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

Chad Greene
Chad Greene 2015년 12월 17일

0 개 추천

Try setting the figure position in the form [xll yll width height] where xll and yll are the x and y positions of the lower left corner of the figure and width and height are, well, the width and height of the figure. Units are in pixels.
set(gcf,'pos',[10 10 300 200])
Jan
Jan 2015년 12월 18일

0 개 추천

This FEX submission is updated soon to support modern Matlab versions: http://www.mathworks.com/matlabcentral/fileexchange/38527-limit-figure-size

댓글 수: 1

Armindo
Armindo 2015년 12월 18일
편집: Armindo 2015년 12월 18일
Hi Jan,
Thank you for the help. I am using your function. I changed the line 99
This: jClient = jFrame.fHG1Client;
for this: jClient = jFrame.fHG2Client;
and now is working.
I just dont understand how is possible that matlab dont have a native function that do this simple thing as well as a function to minimize and maximize a figure. This is a recursive problem that has many years but is never solved...

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

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2015년 12월 17일

댓글:

2015년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by