0
根據我的代碼,我總是有真實的正整數索引。 (i> 1和2i-1> 1,所以我不應該有任何問題)你能看到這裏出了什麼問題嗎?MATLAB - 實數正整數索引
感謝, 艾瑪迪斯
>> vector=tracks(1,2).matrix
vector =
33.7275 96.5223 27.9644
31.7655 95.9838 28.9847
30.6771 95.9896 29.0000
>> length=tracks(1,2).nPoints
length =
3
>> for i=length:-1:1
vector(2i-1,:,:)=vector(i,:,:);
end
Subscript indices must either be real positive integers or logicals.
>> for i=length:-1:1 i end
i =
3
i =
2
i =
1
在這一行中:'for i = length:-1:1'您已經使用了一個,但是兩個內置的Matlab函數作爲變量名稱。一般編程規則:不要將內置函數用作變量名稱。 ps,不要把'i'下標改爲'j'。 'j'也是一個內置函數:-) –
另請參見[this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals -generic-sol)[通用解決此問題](http://stackoverflow.com/a/20054048/983722)。 –