www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@scrollaxes/setRelY.m

    function setRelY(h,val)
%SETRELX   Set an Y position between 0 and 1
%
%  h.setRelY(val)
%

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin<2
   val=get(h.HGobj(2), 'Value');
end

val=max(min(val,1),0);
val=fix(val*2^20)/2^20;

% calc min and max view positions
valsdelt=(h.Ylim(2)-h.Ylim(1))-(h.Yviewlim(2)-h.Yviewlim(1));

if valsdelt
   val=val*valsdelt;
   val=(val+h.Ycenter-valsdelt*0.5);
else
   val=h.Ycenter;
end
h.Yviewpos=val;