Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

Asked by yu on 14 Feb 2013

for example I want to change


How to do it Thank you




No products are associated with this question.

3 Answers

Answer by Jan Simon on 14 Feb 2013

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.


Jan Simon
Answer by Image Analyst on 14 Feb 2013

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 Comment

yu on 18 Feb 2013

I have the problem about the position. The question is below Thanks you for your help

Image Analyst
Answer by yu on 15 Feb 2013

It's well,Thanks Jan Simon and Image Analyst I get the picture by the code

     string ={d;{}};

And then

I add


But the question is the location is changing when I batch like this

|||How to deal with the position question? Thanks|||



Contact us