FROM STRING TO ARRAY

5 次查看(过去 30 天)
ahmad abusara
ahmad abusara 2019-6-30
编辑: Adam Danz 2019-7-2
how i can to change from string like that :
x = ('ABCDE') ;
to array like:
y = [A,B,C,D,E];
  1 个评论
Jan
Jan 2019-6-30
Please explain, what "[A,B,C,D,E];" means. What is the contents of the variables A, B, C, D, E?
If you really want to access variables dynamically by their names: Don't do thia. TUTORIAL: Why and how to avoid EVAL

请先登录,再进行评论。

回答(1 个)

Adam Danz
Adam Danz 2019-6-30
编辑:Adam Danz 2019-7-2
From char to cell array of characters
x = 'ABCDE';
y = num2cell(x);
y =
1×5 cell array
{'A'} {'B'} {'C'} {'D'} {'E'}
...to string array of single characters
ys =string(y)
ys =
1×5 string array
"A" "B" "C" "D" "E"
From String to cell array of characters
x = "ABCDE";
y = num2cell(x{:});

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by