How to remove spaces from a string using while if or for/

Need to use for if or while , finding the length will probably help initiate the loop , but how to remove spaces its complicated
c = 'that is some tick stuf f f'
l = length(c)
for a = 0:l
if c == ' '
c==''
end;
disp(c)

 Respuesta aceptada

It is important that you traverse the string from the end toward the beginning.
c = 'that is some tick stuf f f';
l = numel(c);
for a = l:-1:1
if c(a) == ' '
c(a) = [];
end
end
disp(c)

2 comentarios

Thank you for helping me :)
I am glad to be of help! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 19 de Oct. de 2020

Comentada:

el 19 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by