how can I eliminate space between characters of a string?

13 vues (au cours des 30 derniers jours)
tina jain
tina jain le 11 Mai 2015
e.g. let my string is this t P t P t P t P t P t P t P t P t P t How to convert this string with no white spaces t P t P t P t P t P t P t P t P t P t --->tptptptptptptptptptpt

Réponse acceptée

Guillaume
Guillaume le 11 Mai 2015
Either use strrep or plain matrix element comparison and deletion:
s = 't P t P t P t P t P t P t P t P t P t';
%option 1, strrep:
s1 = strrep(s, ' ', '')
%option 2, comparison and deletion
s2 = s; s2(s2 == ' ') = []

Plus de réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by