how to change multiple elements in a character array at once

Letters = 'vegetables' Hi, I was trying to change the 5th element of the character arrays to the letter X and the last element to the letter Z in one short command. So the final answer will be : Letters = 'vegeXableZ' How can I do it?

 채택된 답변

Stephen23
Stephen23 2018년 9월 4일
편집: Stephen23 2018년 9월 4일
Just use indexing:
Letters([5,end]) = 'XZ'

추가 답변 (1개)

GK
GK 2018년 9월 4일
You can simply use,
Letters(5)='X';
Letters(end)='Z';

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2018년 9월 4일

답변:

GK
2018년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by