【发布时间】:2013-07-10 16:37:30
【问题描述】:
在 Octave 中,我想将字符串转换为字符串矩阵。假设我有一个字符串:
s = "one two three one one four five two three five four"
我想把它拆分成一个矩阵,让它看起来像:
one
two
three
four
five
删除重复项。
这段代码:
words = strsplit(s, ",") %Split the string s using the delimiter ',' and return a cell string array of substrings
只需将矩阵words 创建成与s 完全相同的矩阵。
如何将我的字符串转换为唯一单词的矩阵?
【问题讨论】:
-
你的分隔符应该是空格,而不是逗号。
标签: matlab vector matrix octave