Textscan of a vector with spaces ("32")
1 view (last 30 days)
Show older comments
Dennis Sattelmaier
on 18 May 2015
Commented: Guillaume
on 21 May 2015
Hi,
I have a vector:
Msg=[ 32 52 68 32 50 69 32 51 50 32 52 32 48 32 48 ...]
Now I want to make a textscan and write all values which are separated with a space ("32") and write them into a cell array.
Info: "Msg" is only one vector from an incomming Data matrix.
Question: How can i use the syntax "textscan" for my incomming data, or is there another syntax for scanning a vector for scaces("32") and write them into a cell array?
0 Comments
Accepted Answer
Guillaume
on 18 May 2015
The simplest way is probably:
c = strsplit(char(Msg), ' ')
If you want c to still contain ascii values instead of the corresponding characters:
c = cellfun(@double, strsplit(char(Msg), ' '), 'UniformOutput', false)
4 Comments
Guillaume
on 21 May 2015
Note, in your example just above, the cellfun is completely unnecessary since the output of strsplit is already char.
c = strsplit(char(ReceiveMsg), ' ') %does just the same
c = hex2dec(strsplit(char(ReceiveMsg), ' '))
More Answers (0)
See Also
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!