tags:

views:

72

answers:

1

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!

+6  A: 

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!
Amro
Is there a way one could get a list of all reserved words, like this one, somewhere ? Just so, as a reference of what one should avoid ?
ldigas
I do have this... title 1x4 8 char How do I eliminate this? Many thanks!
mark
Restarting MATLAB did the trick. Many thanks or the help!
mark
no need, just issue the command: `clear title`
Amro
@Idigas: I guess a combination of `iskeyword` and `which` could do that..
Amro
Many thanks for the help Amro!
mark
@Idigas: Another way to check if a name `foo` is already used for a built-in function is to try `help foo` first and see if it returns anything.
gnovice
@Idigas: If you are using the Matlab built-in editor, the keywords are easy to spot - they are the ones in bright blue :)
Richie Cotton

related questions