Swap number with a word

1 visualización (últimos 30 días)
RG
RG el 7 de Mzo. de 2018
Respondida: RG el 7 de Mzo. de 2018
Hi all,
I am wondering how I could swap a number in a vector with a word. I have a vector from 1 to 100 ( linspace(1,100) ) and am trying to replace every fourth number with a word "height". Any suggestion on how to do this?
Thanks.

Respuesta aceptada

Birdman
Birdman el 7 de Mzo. de 2018
a=string(linspace(1,100));
a(4:4:end)=regexprep(a(4:4:end),'\d*','height')

Más respuestas (1)

RG
RG el 7 de Mzo. de 2018
Excellent, thanks!

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by