MATLAB: How to convert data byte by byte

byte conversion

I have read a file and data im getting is shown below. I have to convert this data byte by byte in decimal number please tell me how can I do that ?

Best Answer

Do you really mean byte by byte? The variable read conatins 16 bit characters of the text as unicode, so a byte by byte conversion is:
read = '|0|01|00|5e|'
typecast(uint16(read), 'uint8')
The original text might be a ASCII text, then import it as bytes directly:
fid = fopen('packettext.txt', 'r');
if fid < 0, error('Cannot open file.'); end
bytes = fread(fid, inf, '*uint8');
fclose(fid);
Maybe you want to import the numbers and convert them from hex to decimal?
S = fileread('packettext.txt');
values = sscanf(S, '|%x', [1, inf]);
To clarify this, please post an example with input data and the wanted output.