Swap number with a word

1 回表示 (過去 30 日間)
RG
RG 2018 年 3 月 7 日
回答済み: RG 2018 年 3 月 7 日
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.

採用された回答

Birdman
Birdman 2018 年 3 月 7 日
a=string(linspace(1,100));
a(4:4:end)=regexprep(a(4:4:end),'\d*','height')

その他の回答 (1 件)

RG
RG 2018 年 3 月 7 日
Excellent, thanks!

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by