I have a function in MATLAB that I am using to read some legacy binary files that use Big-endian format for bit ordering. It contains a few lines of code similar to:
fileID = fopen('myBinaryFile.xyz');
structure.fieldnameA = fread(fileID,[1 2],'*unit16','ieee-be');
structure.fieldnameB = fread(fileID,[1 1],'unit16=>char','ieee-be');
fclose(fileID)
Where the sizes and types are picked here arbitarlity. I use the 'machineformat' argument in fread to order the bits correctly. This (appears) to work fine inside the MATLAB environment and I can generate a structure with the data I need.
However, I need to use this functionality inside a simulink model. Attempting to put this function into an embedded MATLAB block returns the error:
> For code generation, you cannot use the 'machineformat' input argument.
I also get a similar error when attempting to use MATLAB coder to generate C/C++ code that could be used in an S-Function.
My question:
Does there exist a code generation friendly version of the machineformat argument? If not, is it possible to write a function that has the same functionality, but is code generation friendly?