How to wrap due to specify the number of columns chars in a picture

조회 수: 7 (최근 30일)
yu
yu 2013년 2월 14일
답변: Chad Greene 2015년 9월 23일
for example I want to change
to
How to do it Thank you

답변 (4개)

Jan
Jan 2013년 2월 14일
The textwrap command is sufficient. As UIHANDLE you can create a temporary object, e.g. uicontrol('Style', 'text', 'visible', 'off') which get the appropriate dimensions.

Image Analyst
Image Analyst 2013년 2월 14일
How did you put that text over that axes control? Did you use the text() function, or is there a static text control on top of the axes?
If you have a text control, like Jan said, you can send your text string, and handle to your control, into textwrap() to get a text with line breaks in it that you can then send to the control with set().
myText = textwrap(handles.text1, reallyLongText);
set(handles.text1, 'String', myText);
Or, if you want to control where the breaks are, you can use sprintf():
myText = sprintf('Line 1\nLine 2\nLine 3');
set(handles.text1, 'String', myText);
You can also use sprintf() with the text() function.
  댓글 수: 1
yu
yu 2013년 2월 18일
I have the problem about the position. The question is below Thanks you for your help

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


yu
yu 2013년 2월 15일
It's well,Thanks Jan Simon and Image Analyst I get the picture by the code
d=txt{2+loopi,4};
h=uicontrol('Style','Text','fontsize',10);
string ={d;{}};
[outstring,newpos]=textwrap(h,string,45);
set(h,'String',outstring,'Position',newpos);
And then
I add
newpos(1)=370;
newpos(2)=230;
But the question is the location is changing when I batch like this
|How to deal with the position question? Thanks|||

Chad Greene
Chad Greene 2015년 9월 23일
Another option is wraptext.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by