Referring to other variables in a variable

9 vues (au cours des 30 derniers jours)
Sam Smith
Sam Smith le 31 Oct 2018
Modifié(e) : the cyclist le 31 Oct 2018
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?

Réponse acceptée

the cyclist
the cyclist le 31 Oct 2018
Modifié(e) : the cyclist le 31 Oct 2018
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.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by