Got Questions? Get Answers.
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

Thread Subject:
displaying strings in multiple lines

Subject: displaying strings in multiple lines

From: IISc geetha

Date: 22 Apr, 2011 20:56:04

Message: 1 of 4

Dear sir,

while using uicontrols when i enter the input for 'string' , i want the string to come in multiple lines.


for eg:- if the ' string' is 'helo world' , i want to display it as

helo
world

can anybody help pls

Subject: displaying strings in multiple lines

From: TideMan

Date: 22 Apr, 2011 23:53:27

Message: 2 of 4

On Apr 23, 8:56 am, "IISc geetha" <ganesh.kolappan.gee...@gmail.com>
wrote:
> Dear sir,
>
> while using uicontrols when i enter the input for 'string' , i want the string to come in multiple lines.
>
> for eg:- if the ' string' is 'helo world'  , i want to display it as
>
> helo
> world
>
> can anybody help pls

disp(['hello' char(10) 'world'])

Subject: displaying strings in multiple lines

From: ImageAnalyst

Date: 23 Apr, 2011 02:53:52

Message: 3 of 4

myString = sprintf('helo\nworld');
set(handleToYourTextControl, 'String', myString);

Or even better:

myString = sprintf('Hello\nworld'); % Hello instead of helo.
set(handleToYourTextControl, 'String', myString);

Subject: displaying strings in multiple lines

From: Yair Altman

Date: 23 Apr, 2011 19:17:04

Message: 4 of 4

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <53705a9e-cf84-4590-9d9f-90b519ef6444@w36g2000vbi.googlegroups.com>...
> myString = sprintf('helo\nworld');
> set(handleToYourTextControl, 'String', myString);
>
> Or even better:
>
> myString = sprintf('Hello\nworld'); % Hello instead of helo.
> set(handleToYourTextControl, 'String', myString);


Unfortunately, the above solution only works for 'text'-style uicontrols, not for GUI uicontrols (buttons, checkboxes etc.).

For GUI uicontrols, you can use HTML formatting, as follows:

uicontrol('style','pushbutton', 'string','<html>Hello<br/><b><i>world!','pos',[20,20,60,60])

More information: http://UndocumentedMatlab.com/blog/html-support-in-matlab-uicomponents/

If you want HTML formatting (including support for colors, fonts, bold/italic etc.) in text labels, read these articles:
http://UndocumentedMatlab.com/blog/customizing-matlab-labels/
http://UndocumentedMatlab.com/blog/syntax-highlighted-labels-panels/

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us