MATLAB: Convert 4char to one double values

data conversion

Hi, I have some data in a byte(char) format that i want to convert to double format. Does anyone tell how to do this in matlab?
I have read the data in to a char, where every 4 characters should represent a double.
My data looks like this :
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
Thanks in advance

Best Answer

There are multiple methods of doing the conversion, depending on the byte order that the numbers were stored in compared to the byte order your machine is using.
Are you certain that you want 4 characters to represent a double, not a single ? If double then is the data representation custom or is the data stored as a single but you want a double as output? That is, double is 64 bits which is 8 bytes and single is 4 bytes.
If your data is a multiple of 4 bytes and each byte was stored to an individual character (the usual), and your byte orders match, and the 4 bytes are in the format of a single, then:
double(typecast(uint8(Data), 'single'))
(But easier would be to read it from the file as numeric.)