Mark
Mark

Reputation: 7596

MATLAB - use a string to set the title of a graph

I'm writing a MATLAB program that reads in a title from the user to set on a graph...

t = input('Please enter a title for the graph: ', 's');

I then want to set the title of my plot to t. I can't seem to get it to work...

title(t)    %# returns ??? Index exceeds matrix dimensions.

Many thanks for the help!

Upvotes: 6

Views: 5053

Answers (1)

Amro
Amro

Reputation: 124563

Make sure in your session you have no variable called title masking the title() function

» whos
  Name       Size     Bytes  Class     Attributes

  t          1x1          2  char                
  title      1x1          8  double              <<<<---- you dont want this!

Upvotes: 8

Related Questions