Effacer les filtres
Effacer les filtres

trim cell array from known characters

2 vues (au cours des 30 derniers jours)
Joseph
Joseph le 21 Juin 2013
Hi There,
How do you trim down a cell array from a space or empty element in the cell and as well remove all commas and semi colons from data?
Variable C is a 654x1 cell containing the first four rows 1x9 cell 1x2 cell 1x29 cell 1x218 cell . . . 1x126 cell
An individual cell array contains spaces I would like to remove. Ultimately I would like to truncate this from space/empty. For example data is as follows:
{AB XY; ' ' ' ' ' ' ' ' ' 'PO,' ' ' ' ' ' SE''''LO,' ' ' ' ' ' W:,TT ...} Where ' ' denotes a space/empty cell. I would like this to become {AB XY PO SE LO W TT} This will truncate the number of columns from the previous 218.
I guess I have to utilize the strtrim or deblank functions not exactly sure how.
Thank You.

Réponse acceptée

Vishal Rane
Vishal Rane le 21 Juin 2013
Assuming
a = {'AB XY';' , PO;';'SE , '}
use
regexprep( a, '[\s;,]', '')
to remove spaces, semicolons and commas, '\s' indicates any whitespace character
  1 commentaire
Joseph
Joseph le 21 Juin 2013
Much Appreciated.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by