Help converting hex string to multiple decimal numbers
显示 更早的评论
I'm trying to parse a data file and convert hex strings into various numerical types. I have data that was correctly parsed using a c program I'm trying to implement in MatLab and I have a sample string and corresponding decimal values.
I have a method that works but I'm wondering if someone could give me a better solution.
My code is below. It correctly parses the hex string into 3 decimal values plus a trailing zero.
Obviously I can delete the final zero but I'd like a more elegant solution that yields only the 3 values.
Any help would be appreciated.
str = '9e2d76007202';
typecast(swapbytes(hex2num(str)),'int16')
ans =
1×4 int16 row vector
11678 118 626 0
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!