Im trying to combine two string together
Afficher commentaires plus anciens
get(handles.OptionsText, 'String')
String = sprintf('\n\n2: ')
set(handles.OptionsText, 'String', sprintf( (get(handles.OptionsText, 'String')), String));
get(handles.OptionsText, 'String') is below:Also the dimensions are 2 14.
1: Rectangular
1.2:
and i have this string: Dimsensions 1 7.
space
space
2:
Whenever i try to combine them it just kinda mashes them. The result is this:
1 : R e c t1a.n2g:u l a r
I would like to have a result of this:
1: Rectangular
1.2:
2:
Réponses (1)
Walter Roberson
le 19 Oct 2016
Skip most of what you have.
String = sprintf('\n\n2: '); %needed to transform the \n into real characters
oldstring = get(handles.OptionsText, 'String');
newstring = [oldstring, String];
set(handles.OptionsText, 'String', newstring );
4 commentaires
Jesse Abruzzo
le 19 Oct 2016
Walter Roberson
le 20 Oct 2016
String = {''; '2:'};
oldstring = cellstr( get(handles.OptionsText, 'String') );
newstring = [oldstring, String];
set(handles.OptionsText, 'String', char( newstring ) );
Jesse Abruzzo
le 21 Oct 2016
Walter Roberson
le 21 Oct 2016
You should create a new Question for that.
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!