Im trying to combine two string together

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:

답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 19일

0 개 추천

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

Jesse Abruzzo
Jesse Abruzzo 2016년 10월 19일
I tried out your code and i am getting an error:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
for this line: newstring = [oldstring, String];
String = {''; '2:'};
oldstring = cellstr( get(handles.OptionsText, 'String') );
newstring = [oldstring, String];
set(handles.OptionsText, 'String', char( newstring ) );
Jesse Abruzzo
Jesse Abruzzo 2016년 10월 21일
I didnt try this code. But i ended up changing my program a bit and dont need this anymore. Thank you for your response! I do have another question about a swuare eave im trying to make if you wanna answer that. Thanks again
Walter Roberson
Walter Roberson 2016년 10월 21일
You should create a new Question for that.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

질문:

2016년 10월 19일

댓글:

2016년 10월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by