類似:グラフの図のサイズの設定
しかし、位置を気にせずに幅と高さを設定したいだけです。望ましい動作は、図を自由にドラッグできることですが、再描画のたびにサイズが固定されます。
上記のリンクの方法は好きではありません。位置の (x,y) 座標を指定する必要があるためです。これは、コードが開発されたり、別のコンピューターを使用したりすると面倒です。しかし、おそらくその set() 関数を使用するよりスマートな方法はありますか?
編集:以下のクールな@回答、これが私の更新された関数です。もう 1 つは、図が常に焦点を合わせないように「沈黙」することです。
function h = sfigure(h,s1,s2)
% SFIGURE Create figure window (minus annoying focus-theft).
%
% Usage is identical to figure.
%
% Daniel Eaton, 2005
%
% See also figure
%
% Modified by Peter Karasev, 2012, to 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