3 回答
TA贡献1825条经验 获得超4个赞
下标指数必须是实数正整数或逻辑值。
dbstop if error
1。在某个地方,无效索引用于访问变量。
variableName(index,index)variableName{index,index}variableName{indices}(indices)
f9
isequal(index, round(index))
isequal(x, max(1,round(abs(x))))
class(index)
2。函数名已被用户定义的变量遮蔽。
max = 9
max
max
max([1 8 0 3 7])
max
0
()
which
.
实例
无效索引的简单出现
a = 1;b = 2;c = 3;a(b/c)
b/c
无效指数的复杂发生
a = 1;b = 2;c = 3;d = 1:10;a(b+mean(d(cell2mat({b}):c)))
d
cell2mat({b}):c
b+mean(d(cell2mat({b}):c))
a
.
b/c
重载函数
which mean % some directory\filename.m
a = 1:4;b=0:0.1:1;mean(a) = 2.5;mean(b);
mean
which mean% mean is a variable.
TA贡献1862条经验 获得超7个赞
a(a+a)
a*(a+a)
>> a=0a = 0>> a*(a+a)ans = 0>> a(a+a)Subscript indices must either be realpositive integers or logicals.
添加回答
举报