Info
This question is closed. Reopen it to edit or answer.
how to get an array from a number string
1 view (last 30 days)
Show older comments
I need to extract single elements from a code such 4 digit in a six digit code which is expressed as a string.
0 Comments
Answers (1)
Star Strider
on 19 Oct 2015
Edited: Star Strider
on 19 Oct 2015
This works:
nstr = '123456';
first_four = nstr(1:4)
first_four =
1234
EDIT — If you want it as a number instead of a string, then use str2num or str2double.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!