Tags: dlike, figure, loop, matlab, plot, programming, time, variable, win

Use a variable in title of figure

On Programmer » Matlab

1,954 words with 2 Comments; publish: Wed, 30 Apr 2008 17:55:00 GMT; (20091.80, « »)

Hi,

I'm using Matlab 6.1(win).

I'd like to plot some data at different times using a for loop. I'd

like to add the time to the title of the figure.

so something like this...

CurrentTime = 0.2

figure(2),title('Time: CurrentTime')

However, title() only accepts strings. Is there a way to print a

variable value to the figure's background or title?

Thanks,

All Comments

Leave a comment...

  • 2 Comments
    • psychobyte wrote:

      >

      > Hi,

      > I'm using Matlab 6.1(win).

      > I'd like to plot some data at different times using a for loop.

      > I'd

      > like to add the time to the title of the figure.

      > so something like this...

      > CurrentTime = 0.2

      > figure(2),title('Time: CurrentTime')

      > However, title() only accepts strings. Is there a way to print a

      > variable value to the figure's background or title?

      > Thanks,

      use SPRINTF

      title(sprintf('Time: %.2f',CurrentTime)) ;

      hth

      Jos

      #1; Wed, 30 Apr 2008 17:56:00 GMT
    • On Thu, 7 Apr 2005 02:33:42 -0400 in message

      <news:ef01686.-1.matlab.todaysummary.com.webx.raydaftYaTP>, psychobyte wrote:

      > Hi,

      > I'm using Matlab 6.1(win).

      > I'd like to plot some data at different times using a for loop. I'd

      > like to add the time to the title of the figure.

      > so something like this...

      > CurrentTime = 0.2

      > figure(2),title('Time: CurrentTime')

      > However, title() only accepts strings. Is there a way to print a

      > variable value to the figure's background or title?

      > Thanks,

      Hi!

      Ct=0.2

      title(['Time: ' num2str(Ct)])

      HTH

      PB

      --

      A: Because it messes up the order in which people normally read text.

      Q: Why is top-posting such a bad thing?

      A: Top-posting.

      Q: What is the most annoying thing on usenet and in e-mail?

      #2; Wed, 30 Apr 2008 17:57:00 GMT