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:
Linebreak in title

Subject: Linebreak in title

From: Silenius

Date: 6 Apr, 2011 17:39:05

Message: 1 of 5

Hi all,

my question is pretty simple: I plot a figure and would like to add a title. Since the latter is long, I would like to make a linebreak, i.e. to start a new line. How can this be done? Seems that '\n' which is for instance used in "fprintf" doesn't work within the "title" command :(.

Thanks and cheers!

Subject: Linebreak in title

From: Florin Neacsu

Date: 6 Apr, 2011 18:15:21

Message: 2 of 5

"Silenius" wrote in message <ini8fp$2qc$1@fred.mathworks.com>...
> Hi all,
>
> my question is pretty simple: I plot a figure and would like to add a title. Since the latter is long, I would like to make a linebreak, i.e. to start a new line. How can this be done? Seems that '\n' which is for instance used in "fprintf" doesn't work within the "title" command :(.
>
> Thanks and cheers!

Hello,

Try this

<pre class="code">
title(strvcat('Line1','Line2'))
</pre>

Hope it helps.
Florin
P.S. Sorry for the <> tags. I am trying to see if this works on the reader. The blogs seem to support it.

Subject: Linebreak in title

From: Wayne King

Date: 6 Apr, 2011 18:19:05

Message: 3 of 5

"Silenius" wrote in message <ini8fp$2qc$1@fred.mathworks.com>...
> Hi all,
>
> my question is pretty simple: I plot a figure and would like to add a title. Since the latter is long, I would like to make a linebreak, i.e. to start a new line. How can this be done? Seems that '\n' which is for instance used in "fprintf" doesn't work within the "title" command :(.
>
> Thanks and cheers!

Hi Silenius,

One way.

plot(randn(100,1));
str = {'This is the first line', 'This is the second line'}'
title(str)

Wayne

Subject: Linebreak in title

From: Silenius

Date: 6 Apr, 2011 18:45:38

Message: 4 of 5

"Wayne King" <wmkingty@gmail.com> wrote in message <iniaqp$ed1$1@fred.mathworks.com>...
> "Silenius" wrote in message <ini8fp$2qc$1@fred.mathworks.com>...
> > Hi all,
> >
> > my question is pretty simple: I plot a figure and would like to add a title. Since the latter is long, I would like to make a linebreak, i.e. to start a new line. How can this be done? Seems that '\n' which is for instance used in "fprintf" doesn't work within the "title" command :(.
> >
> > Thanks and cheers!
>
> Hi Silenius,
>
> One way.
>
> plot(randn(100,1));
> str = {'This is the first line', 'This is the second line'}'
> title(str)
>
> Wayne

Hi Wayne,

thanks for the suggestion, works perfectly well!

Subject: Linebreak in title

From: ImageAnalyst

Date: 6 Apr, 2011 18:48:03

Message: 5 of 5

Silenius
But sprintf() works perfectly fine. Perhaps your problem was using
fprintf instead of sprintf()

plot(randn(100,1));
caption = sprintf('This is the first line.\nThis is the second line');
title(caption)

Tags for this Thread

No tags are associated with 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