Based on one of your comments, it seems your hexadecimal values ββare stored as character strings in a file. First you want to read these characters from the file in groups of 8. Depending on the specific format of your file (for example, each set of 8 characters is on a separate line or they are separated by commas, etc.), you can use functions such as FSCANF or TEXTSCAN to do this. For example, if your data file looks like this:
409BFFFF 3B3C0000 85E60000
Then you can read the data in an array of characters as follows:
fid = fopen(fileName,'r'); %
Now you need to convert these 32-bit hex strings to representations with one precision. The easiest way is to use the HEX2DEC function to convert strings to integers (stored as double precision values), convert them to unsigned 32-bit integers using the UINT32 function, then convert 32-bit integers to single-precision representations using TYPECAST function. Applying this to the sample data given above, the following results are given:
>> values = typecast(uint32(hex2dec(charArray)),'single'); >> fprintf('% 1.42f\n',values); %
You can confirm that these results are correct using this converter with a hexadecimal convertible point in HTML format .
In case anyone is interested, you can do the type conversion above yourself, using the HEX2DEC function to first convert the string to an integer representation, then the BITGET function to extract and process the bits for the sign, exponent and fraction of the number with the same precision . For instance:
>> a = '409BFFFF'; %
source share