字符串矩阵的分隔列输出
Separated columns output for matrix of strings
让具有字符串值的矩阵定义如下:
A = ["abc" "abd" "e"];
Octave 打印如下:
A = abcabde
虽然我需要一个单独的视图:
A = abc abd e
有什么办法可以实现吗?
UPD:我不能使用 {"abc" "abd" "e"}
,因为在这种情况下我不能使用 perms(A)
函数 - 它会给出错误的结果。
我不知道八度,但 MATLAB 允许使用 'perms' 置换元胞数组中的字符串。如果 Octave 没有,如何在字符串元胞数组中置换索引?
A = {'abc', 'def', 'g'};
idx = 1:3;
idx2 = perms(idx);
>> A(idx2)
ans =
'g' 'def' 'abc'
'g' 'abc' 'def'
'def' 'g' 'abc'
'def' 'abc' 'g'
'abc' 'def' 'g'
'abc' 'g' 'def'
让具有字符串值的矩阵定义如下:
A = ["abc" "abd" "e"];
Octave 打印如下:
A = abcabde
虽然我需要一个单独的视图:
A = abc abd e
有什么办法可以实现吗?
UPD:我不能使用 {"abc" "abd" "e"}
,因为在这种情况下我不能使用 perms(A)
函数 - 它会给出错误的结果。
我不知道八度,但 MATLAB 允许使用 'perms' 置换元胞数组中的字符串。如果 Octave 没有,如何在字符串元胞数组中置换索引?
A = {'abc', 'def', 'g'};
idx = 1:3;
idx2 = perms(idx);
>> A(idx2)
ans =
'g' 'def' 'abc'
'g' 'abc' 'def'
'def' 'g' 'abc'
'def' 'abc' 'g'
'abc' 'def' 'g'
'abc' 'g' 'def'