Swap number with a word

2 visualizzazioni (ultimi 30 giorni)
RG
RG il 7 Mar 2018
Risposto: RG il 7 Mar 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.

Risposta accettata

Birdman
Birdman il 7 Mar 2018
a=string(linspace(1,100));
a(4:4:end)=regexprep(a(4:4:end),'\d*','height')

Più risposte (1)

RG
RG il 7 Mar 2018
Excellent, thanks!

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by