Iulius Caesar
Iulius Caesar

Reputation: 83

Delete ' signs out of multiple cells in matlab

I have got a 2x5 cell-array containing char strings. E.g. it looks like this:

{'''ABC''' , '''DEF''' , '''GHI'''   , '''-'''   , '''MNO'''; ...
'''PQR''' , '''STU''' , '''Value''' , '''XYZ''' , '''-'''}

So for example, if I give out one cell, the output is following: ''ABC''. Now I want the output to be 'ABC'. How can i delete all ' of the cells?

Upvotes: 0

Views: 34

Answers (1)

Dan
Dan

Reputation: 45752

So basically you just want to loop through each element of the cell array and drop the first and the last character:

A = {'''ABC''' , '''DEF''' , '''GHI'''   , '''-'''   , '''MNO''';'''PQR''' , '''STU''' , '''Value''' , '''XYZ''' , '''-'''}

cellfun(@(x)x(2:end-1),A,'uni',0)

Upvotes: 2

Related Questions