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)
Ravneet Panech
Ravneet Panech on 19 Oct 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
I need to extract single elements from a code such 4 digit in a six digit code which is expressed as a string.

Answers (1)

Star Strider
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.

Tags

Community Treasure Hunt

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

Start Hunting!