function r = cast(x,classname)
% Embedded MATLAB Library function.
%
% Limitations:
% Only supports single, double, logical, char, and 8, 16, and 32 bit 
% signed and unsigned integer classes.

% Copyright 2002-2004 The MathWorks, Inc.

eml_assert(nargin >= 2,'Not enough input arguments.');
eml_assert(ischar(classname),'classname must be a string.');

switch classname
    case 'int32'
        r = int32(x);
    case 'uint32'
        r = uint32(x);
    case 'double'
        r = double(x);
    case 'single'
        r = single(x);
    case 'int8'
        r = int8(x);
    case 'int16'
        r = int16(x);
    case 'uint8'
        r = uint8(x);
    case 'uint16'
        r = uint16(x);
    case 'logical'
        r = logical(x);
    case 'char'
        r = char(x);
    otherwise
        eml_assert(0,'error','Unsupported class.');
end
