MATLAB Answers

Left of a string

53 views (last 30 days)
Matthew
Matthew on 14 Apr 2014
Commented: Matthew on 14 Apr 2014
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.

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Apr 2014
cellfun(@(S) S(1:13), key_value, 'Uniform', 0)

  1 Comment

Matthew
Matthew on 14 Apr 2014
Walter, you're a star!
Thanks for your help!

Sign in to comment.

More Answers (1)

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

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags