Referring to other variables in a variable

Say I have a variable that contains a string array: date='1 October 2018' I want to create a new variable containing that variable plus something else (say 'hjhjhj'), like: newdate=date+'hjhjhj' How do I do this? Do I have to convert to their numeric values?

 채택된 답변

the cyclist
the cyclist 2018년 10월 31일
편집: the cyclist 2018년 10월 31일

1 개 추천

The way you have defined date there, it is a character array, not a string array. In that case, you can simply concatenate them like this:
date='1 October 2018'
newdate = [date 'hjhjhj']
If you really have a string array (which is its own data type), then use the strcat command.

추가 답변 (0개)

카테고리

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

질문:

2018년 10월 31일

편집:

2018년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by