cast
Cast variable to different data type
Syntax
Description
converts B = cast(A,"like",p)A to the same numerictype and fimath properties as
p. The complexity (real or complex) of
B is determined by both A and
p. If A and p are
both real, then B is also real. Otherwise,
B is complex.
Examples
Input Arguments
Tips
Use the B = cast(A,"like",p) syntax to specify data types
separately from algorithm code. This strategy allows you to:
Reuse your algorithm code with different data types.
Keep your algorithm uncluttered with data type specifications and switch statements for different data types.
Improve readability of your algorithm code.
Switch between fixed-point and floating-point data types to compare baselines.
Switch between variations of fixed-point settings without changing the algorithm code.
