FreeMat

- Main Page
- Related Pages

CTYPETHAW Convert C Struct to FreeMat Structure

Section: FreeMat External Interface

# Usage

The `ctypethaw` function is used to convert a C structure that is encoded in a byte array into a FreeMat structure using a C structure typedef. To use the `ctypethaw` function, you must first define the type of the C structure using the `ctypedefine` function. The usage of `ctypethaw` is

      mystruct = ctypethaw(byte_array, 'typename')

where `byte_array` is a `uint8` array containing the bytes that encode the C structure, and `typename` is a string that contains the type description as registered with `ctypedefine`. If you want to retrieve multiple structures from a single byte array, you can specify a count as

      mystruct = ctypethaw(byte_array, 'typename', count)

where `count` is an integer containing the number of structures to retrieve. Sometimes it is also useful to retrieve only part of the structure from a byte array, and then (based on the contents of the structure) retrieve more data. In this case, you can retrieve the residual byte array using the optional second output argument of `ctypethaw`:

      [mystruct,byte_array_remaining] = ctypethaw(byte_array, 'typename',...)