![](https://csdnimg.cn/release/download_crawler_static/35454557/bg6.jpg)
set(0, ‘DefaultFigurePaperOrientation ’ ,value)
set(Hf, ‘PaperOrientation ’ ,value)
elseif Name(1)== ‘t’
set(0, ‘DefaultFigurePaperType ’ ,value)
set(Hf, ‘PaperType’ ,value)
elseif Name(1)== ‘u’
set(0, ‘DefaultFigurePaperUnits ’ ,value)
set(Hf, ‘PaperUnits’ ,value)
else
disp([ ‘Unknown Property Name: ’ Name])
ens
end
end
当把对象放在一个特定的位置时,有时在象素和归一化坐标之间进行转化是很有用的。在
精通 MATLAB 工具箱中有两个函数进行这种转换。第一个是 mmpx2n,它将象素转化为归一
化坐标;第二个是 mmn2px,它进行相反的转换。这些函数演示了如何以所需的一组单位获取
‘Position’属性值。首先,把对象的当前 ‘Units’属性保存起来;然后,将 ‘Units’属性设成所
需的值并获取所需的 ‘Position’属性值;最后,将 ‘Units’的值恢复为初始值。 mmpx2n 的 M
文件描述如下:
function Y=mmpx2n(X,Hf)
%MMPX2N Pixel to Normalized Coordinate Transformation.
% MMPX2N(X) converts the Position vector X from pixel coordinates to normalized
% coordinates w.r.t.the computer screen.
%
% MMPX2N converts the Position vector X from pixel coordinate to narmalized coordinates
% w.r.t.the figure windoiw having handle H.
%
% X=[left bottom width height] or X=[width height]
% Copyright (c) 1996 by Prentice-Hall,Inc.
msg= ‘Input is not a pixel Position vector. ’ ;
lx=length(X);
sz= ‘Position ’ ;
if nargin==1,Hf=0;sz= ‘ScreenSize’ ;end
if any(X<1)| (lx~=4&lx~=2)
error(msg)