adding letters to string

2 vues (au cours des 30 derniers jours)
Max
Max le 8 Nov 2015
Say I start of with an empty string x=''
And I input something random say 'd' I would like x='d' then If I input a second thing say 'e' I would like x to then display x='de' and so on
Thanks
  1 commentaire
per isakson
per isakson le 8 Nov 2015
Input how?

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 8 Nov 2015
x = 'd'
x(end+1) = 'e'

per isakson
per isakson le 8 Nov 2015
Assuming "input" means that a user inputs letters interactively
str = '';
buf = {''};
while not( isempty( buf ) )
str = cat( 2, str, buf{1} );
buf = inputdlg( 'input one letter: ' );
end
str
and quit the loop with the [Cancel] button

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