📄 convert.m
字号:
function mm = convert(mm,datatype,siz)
%CONVERT Configures properties for predefined target data types
% CONVERT(MM,TYPE) - Defines the numeric representation to be
% applied to the register object MM. The TYPE input defines
% some common data types. This method adjusts the properties
% of MM object to match the specified TYPE. As a result,
% future READ/WRITE operations will apply the appropriate
% data conversion to implement the numeric representation.
% For uncommon datatypes, it is possible to directly modify
% the MM properties, but generally it is better to use the CONVERT
% method.
%
% CONVERT(MM,TYPE,SIZE) - Does an additional reshaping - adjusts the
% 'size' property - of the MM object.
%
% Note: SIZE is always 1 for bit fields.
%
% See also CAST, COPY.
% Copyright 2002 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2002/05/13 18:31:50 $
error(nargchk(2,3,nargin));
if ~ishandle(mm),
error('First Parameter must be a BITFIELD Handle.');
end
if ~ischar(datatype),
error('Second Parameter must be a string.');
end
if nargin==3
if ~isnumeric(siz),
error('Third Parameter must be numeric.');
else
if prod(siz)~=1
error('Bitfield cannot have size>1 ');
end
end
end
% Change to specified datatype
mm.prepad = 0; % Modified later, if necessary
mm.postpad = 0;
switch datatype
case 'int'
if strcmp(mm.procsubfamily(1:2),'C6'), % C6x
totalbits = 32;
elseif strcmp(mm.procsubfamily,'C54x'), % C5x
totalbits = 16;
end
mm.storageunitspervalue = round(totalbits/mm.bitsperstorageunit);
mm.represent = 'signed';
case 'unsigned int'
if strcmp(mm.procsubfamily(1:2),'C6'), % C6x
totalbits = 32;
elseif strcmp(mm.procsubfamily,'C54x'), % C5x
totalbits = 16;
end
mm.storageunitspervalue = round(totalbits/mm.bitsperstorageunit);
mm.represent = 'unsigned';
otherwise,
error(['DATATYPE:' datatype ' is not supported']);
end
% reshape size (to 1)
if nargin==3, set(mm,'size',siz); end;
% [EOF] convert.m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -