我有一个函数func
,它返回一个向量a
。我通常会绘制一个然后对其进行进一步分析。当我尝试绘制一个图形时,有一定的场景,我收到“??? Subscript indices must either be real positive integers or logicals
”错误。看看下面的一段代码来看看向量的行为:奇怪的Matlab错误:“???下标索引必须是真正的正整数或逻辑”
K>> a
a =
5.7047 6.3529 6.4826 5.5750 4.1488 5.8343 5.3157 5.4454
K>> plot(a)
??? Subscript indices must either be real positive integers or logicals.
K>> for i=1:length(a); b(i) = a(i); end;
K>> b
b =
5.7047 6.3529 6.4826 5.5750 4.1488 5.8343 5.3157 5.4454
K>> plot(b)
??? Subscript indices must either be real positive integers or logicals.
在那里当我打电话功能func
从另一个函数内发生这种情况时的场景(称之为outer_func
),并直接为outer_func
返回结果结果。在outer_func
内部进行调试时,我可以正确绘图,但不在outer_func
的范围内,其结果具有上述行为。
这是什么原因造成的?我从哪里开始?
另请参阅[此问题](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol)for [generic解决此问题的方法](http://stackoverflow.com/a/20054048/983722)。 – 2013-11-27 15:45:13