【问题标题】:MATLAB - use a string to set the title of a graphMATLAB - 使用字符串设置图的标题
【发布时间】:2010-02-20 23:00:38
【问题描述】:

我正在编写一个 MATLAB 程序,它从用户那里读取一个标题以在图形上设置...

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

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

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

非常感谢您的帮助!

【问题讨论】:

  • 为什么这被否决了,我无法理解...... +1 反对

标签: matlab


【解决方案1】:

确保在您的会话中没有名为 title 的变量掩盖了 title() 函数

» whos
  Name       Size     Bytes  Class     Attributes

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

【讨论】:

  • 有没有办法在某处获得所有保留字的列表,比如这个?就这样,作为一个应该避免什么的参考?
  • 我确实有这个... title 1x4 8 char 如何消除这个?非常感谢!
  • @Idigas:检查名称foo 是否已用于内置函数的另一种方法是先尝试help foo,看看它是否返回任何内容。
  • @Idigas:如果您使用的是 Matlab 内置编辑器,关键字很容易发现——它们是亮蓝色的 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多