필터 지우기
필터 지우기

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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by