MATLAB Answers

0

How to get double array from string

Asked by Ümit Güden on 25 Oct 2019
Latest activity Commented on by Ümit Güden on 25 Oct 2019
Hi everyone,
I have a edit box in which I want to enter an array like
1:5
or
[1,2,3,5]
or
[1,2,3:6,9,12:15]
. Since this is edit an edit box when I read the box I get string.
Is there an easy way of converting this string version of double array to a real double array.
For example when I enter the
'[1,2,3:6,9,12:15]'
to edit box I want to get the double array
A= [1,2,3:6,9,12:15]
which is equal to
[1 2 3 4 5 6 9 12 13 14 15]
Thanks in advance.

  0 Comments

Sign in to comment.

1 Answer

Answer by Stephan
on 25 Oct 2019
Edited by Stephan
on 25 Oct 2019
 Accepted Answer

>> A = str2num('[1,2,3:6,9,12:15]')
A =
1 2 3 4 5 6 9 12 13 14 15

  1 Comment

Thanks @Stephan.

Sign in to comment.