Skip to Main Content Skip to Search
Product Documentation

cast - Cast variable to different data type

Syntax

B = cast(A, newclass)

Description

B = cast(A, newclass) converts A to class newclass, where newclass is the name of a built-in data type compatible with A. The cast function truncates any values in A that are too large to map into newclass.

Examples

Convert an int8 value to uint8:

a = int8(5);
b = cast(a,'uint8');
class(b)

MATLAB returns:

ans =
uint8

See Also

class | typecast

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS