How to convert a matrix to a string array:

1 次查看(过去 30 天)
I have a matrix:
R=[1 2 1 3 2 3 1;1 1 2 1 2 2 3];
that i want to convert to:
Q=["A11","A21","A12","A31","A22","A32","A13"];
How can I do that?
Appreciated!

采纳的回答

Andrei Bobrov
Andrei Bobrov 2021-5-9
"A" + R(1,:)' + R(2,:)'
  4 个评论
Walter Roberson
Walter Roberson 2021-5-10
cell2mat(arrayfun(@(s)sscanf(s, "%*c%1d%1d"),Q,'UniformOutput',false)).'

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2021-5-9
R=[1 2 1 3 2 3 1;1 1 2 1 2 2 3]
R = 2×7
1 2 1 3 2 3 1 1 1 2 1 2 2 3
compose("A%d%d", R(1,:).', R(2,:).').'
ans = 1×7 string array
"A11" "A21" "A12" "A31" "A22" "A32" "A13"

类别

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