how to remove the first 5 characters from a cell array 343x1 cell
Show older comments
Hello all, I would like to remove the first few characters from every single cell (343), yet I am not much aware of how to do it. I tried to solve the problem via googling it yet could not find anything that would fit my case. The cell array is attached. Example: for "d035-117" for instance i would like to convert it into a form of "117". The first 5 characters need to be truncated. Thanks for your advices and help in advance!
2 Comments
Jack
on 7 Dec 2022
Do you have the answer already, because i don't get it too?
Image Analyst
on 7 Dec 2022
@Jack you can see he accepted my answer below so I guess it worked for him.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Accepted Answer
More Answers (1)
Jos (10584)
on 27 Oct 2015
Edited: Jos (10584)
on 27 Oct 2015
If A is your cell-array of strings, this oneliner will do the job:
B = cellfun(@(x) x(1:end-5), A, 'un', 0)
2 Comments
NU_YU
on 27 Oct 2015
Leone Campos
on 5 Jan 2023
For those who are wondering what 'un' is, it stands for 'UniformOutput'.
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!