Skip to content

cast

miscellaneous · scripts/miscellaneous/cast.m

: b = cast (a, newclass)
: b = cast (a, "like", p)

Convert a to class newclass, or to the class (and sparsity) of prototype p.

Out-of-range values saturate to the nearest endpoint of the destination integer type. With "like", complexity follows MATLAB R2026a: the result is complex unless both a and p are real.