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():c)))
d
cell2mat():c
b+mean(d(cell2mat():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.
添加回答
舉報