Left of a string

13 次查看(过去 30 天)
Matthew
Matthew 2014-4-14
评论: Matthew 2014-4-14
Hello, I have a column in my table array called key_value.
The array contains a string such as '1234567891234|XYZ|9999'.
How do I code for each of these cells extract the first 13 characters?
I have tried key_value(1:13) but this does not work and simply pulls out the first 13 rows of records.

采纳的回答

Walter Roberson
Walter Roberson 2014-4-14
cellfun(@(S) S(1:13), key_value, 'Uniform', 0)
  1 个评论
Matthew
Matthew 2014-4-14
Walter, you're a star!
Thanks for your help!

请先登录,再进行评论。

更多回答(1 个)

Nitin
Nitin 2014-4-14
If you are accessing a cell array, you should use curly braces. Check out the examples here

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by