Read hex data from txt file and convert to signed integer

Dear members, I have a text file that has 10 bit singed hexadecimal numbers. I want to convert it to signed integers. I am attaching the text file for testing as well. Thanks in advance.

 채택된 답변

Usman Ashraf
Usman Ashraf 2018년 2월 4일
I just figured out the answer myself and am sharing here for others.
filename = 'Filter_Output.txt';
q = quantizer('fixed', 'nearest', 'saturate', [10 0]);% quantizer object for num2hex function
FID = fopen(filename);
dataFromfile = textscan(FID, '%s');% %s for reading string values (hexadecimal numbers)
dataFromfile = dataFromfile{1};
decData = hex2num(q, dataFromfile);
decData = cell2mat(decData);
fclose(FID);

댓글 수: 2

Thanks Usman! I needed to do the same thing!
Glad to know it helped :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2018년 2월 4일

댓글:

2018년 11월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by