Indexing result of strsplit('My string', ' ')

43 次查看(过去 30 天)
Why doesn't something like
strsplit('My string', ' ')(1)
work?
Is there a more elegant way than
x = strsplit('My string', ' ')
x(1)

采纳的回答

Guillaume
Guillaume 2018-6-20
No matlab does not allow indexing directly into the return value of a function (or any other temporary variable). There is not workaround other than assigning the temporary to a variable, as you have done.
Note that if you want the content of the first element of the cell array {} would be more appropriate
x = strsplit('My string', ' ')
x{1}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by