How to convert Hex data into decimal data?
이전 댓글 표시
Hi,
I have to convert the hex data I have into one decimal array. I am not able to use this data as input for following reasons.
1. MATLAB is unable to import this data file(data.m)
2. While defining the data in matrix or cell form is giving an error at each element which contains number and string(Example: 0A B5)
Example:(data.m) B5 62 0A 04 00 00 0E 34 B5 62 0D 01 10 00 A0 9A D9 13 00 00 00 00 CB F3 FF
Code:
t=25;
for n=1:1:t
count_hex = count_hex + 1;
A = data(1,n);
B(:,count_hex) = hex2dec(A);
end
What can I do to make it work?
채택된 답변
추가 답변 (2개)
Jan
2015년 3월 28일
2 개 추천
sscanf('%x') is much faster than hex2dec.
댓글 수: 2
Jos (10584)
2015년 3월 29일
+1
... but you'll need a loop around the cell array, or a call to CELLFUN. In my opinion this make the code a little less clear.
yahia mohammad
2021년 9월 2일
편집: yahia mohammad
2021년 9월 2일
HOW TO CONVERT '49204C6F76' TO DECIMAL BY USING MATLAB
Vivek Deshmukh
2015년 3월 28일
0 개 추천
USE COMMAND HEX2DEC
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!