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 的更多信息

产品

版本

R2018b

提问:

2019-2-8

Community Treasure Hunt

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

Start Hunting!

Translated by