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

31 visualizaciones (últimos 30 días)
Nicolas Bourbaki
Nicolas Bourbaki el 20 de Jun. de 2018
Comentada: Nicolas Bourbaki el 24 de Jul. de 2018
Why doesn't something like
strsplit('My string', ' ')(1)
work?
Is there a more elegant way than
x = strsplit('My string', ' ')
x(1)

Respuesta aceptada

Guillaume
Guillaume el 20 de Jun. de 2018
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}
  1 comentario
Nicolas Bourbaki
Nicolas Bourbaki el 24 de Jul. de 2018
Thanks a lot for your answer. It helps me a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by