필터 지우기
필터 지우기

adding letters to string

조회 수: 3 (최근 30일)
Max
Max 2015년 11월 8일
답변: per isakson 2015년 11월 8일
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

답변 (2개)

Walter Roberson
Walter Roberson 2015년 11월 8일
x = 'd'
x(end+1) = 'e'

per isakson
per isakson 2015년 11월 8일
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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by