user interface - matlab, setting default figure size, but don't care about position? -


similar to: setting graph figure size

but, want set width , height, without caring position. desired behavior can drag figure around @ will, on each re-draw size fixed.

i don't method in above link because must provide (x,y) coordinate position, annoying code develops or use different computers. perhaps there smarter way use set() function?

edit: cool @ answer below, here's updated function. other thing "silent" figure doesn't pull focus constantly.

function h = sfigure(h,s1,s2) % sfigure  create figure window (minus annoying focus-theft). % % usage identical figure. % % daniel eaton, 2005 % % see figure % % modified peter karasev, 2012, optionally set scale %  if nargin>=1      if ishandle(h)         set(0, 'currentfigure', h);     else         h = figure(h);     end else     h = figure; end  if( nargin > 1 )   scalex = s1;   scaley = s1;   if( nargin > 2 )     scaley = s2;   end   pos = get(h,'position');   pos(3:4) = [400 300].*[scalex scaley];   set(gcf,'position',pos); end 

combine corresponding get function:

figure pos = get(gcf,'position'); pos(3:4) = [w h]; set(gcf,'position',pos); 

this keep default position , change width , height.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -