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.'); endbytes = 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. Related SolutionsMATLAB: Fwrite and fread data of multiple precision to binary file You need to fseek() to skip the first 6 bytes of the file. MATLAB: Gpu computation is slow sometimes Some operations using gpuArray don't complete synchronously, so using tic and toc can give you misleading timings. You should use gputimeit to time gpuArray operations to get reliable timings. Related QuestionCan anyone read this file with matlabGetting ‘0F’ instead of ‘F’ for dec2hex(15)Where can I see how much time it takes to simulate a .m fileGets imellipse slower and slower in a loop
Best Answer