MATLAB - 使用字符串设置图表的标题

Mar*_*ark 6 matlab

我正在编写一个MATLAB程序,该程序从用户读入标题以设置图表...

t = input('Please enter a title for the graph: ', 's');
Run Code Online (Sandbox Code Playgroud)

然后我想将我的情节标题设置为t.我似乎无法让它工作......

title(t)    %# returns ??? Index exceeds matrix dimensions.
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助!

Amr*_*mro 8

确保在您的会话中没有名为titlemasking the title()function的变量

» whos
  Name       Size     Bytes  Class     Attributes

  t          1x1          2  char                
  title      1x1          8  double              <<<<---- you dont want this!
Run Code Online (Sandbox Code Playgroud)

  • 没有必要,只需发出命令:`clear title` (2认同)