0xF2
0xF2

Reputation: 310

Type casting in Matlab

What is the proper way to cast data types in Matlab?

I have my data stream (instrument data) as undifferentiated elements of a uint8 array, which I want to cast into a composite data types, like for instance a 3-byte, 24-bit integer, or a 3-byte, 3 character string.

I normally do this on the fly specifying a format in fread(), but once the data is already in a uint8 array, is typecast() the proper way to go about it, or is there a nicer syntax?

Upvotes: 2

Views: 424

Answers (1)

OmG
OmG

Reputation: 18858

As I know, there is not any data type for integer 3 or 24 bytes (see documentaion). However, about casting from uint8 to string, it can be done by num2str function (like num2str(uint8(123)). Also if you want get a 2 char string (from left) you can do it by num2str(uint8(123))(end-1:end);

Upvotes: 1

Related Questions