www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgprecpolyfix/phys2hw.m
function HWValues = phys2hw(POLYFIXPREC, PhysValues) %PHYS2HW Convert physical values to hardware values. % % HWValues = PHYS2HW(POLYFIXPREC, PhysValues) converts physical values % PhysValues to hardware values HWValues using a polynomial-based mapping % from physical values to hardware values specified by the cgprecpolyfix % object POLYFIXPREC. % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. % Error check on PhysValues PhysValues = i_check(POLYFIXPREC, PhysValues, 'PhysValues'); % Resolve to admissible physical values PhysValues = physresolve(POLYFIXPREC, PhysValues); % Fetch polynomial coefficients for the physical to hardware conversion NumCoeff = get(POLYFIXPREC, 'NumCoeff'); DenCoeff = get(POLYFIXPREC, 'DenCoeff'); % Convert physical values to continuous pseudo-hardware values HWValues = polyval(NumCoeff,PhysValues)./polyval(DenCoeff,PhysValues); % Round the pseudo-hardware values to the nearest admissible values HWValues = hwresolve(POLYFIXPREC, HWValues); % ------------------------------------------------------------------------- function out = i_check(Prec, in, VarName) % Check input variables switch VarName case 'PhysValues' if pCheckNumeric(Prec, in, true, 'PhysValues') % PhysValues is valid out = in; end end