Help converting hex string to multiple decimal numbers
Show older comments
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
Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!