作者ljuyentintho (小劉)
看板MATLAB
標題[討論]這個bug求解
時間Wed Apr 20 02:33:01 2016
程式碼如下:
r=3
a=3
O1 = ones(1, a);
AraPatient = ones(1,r*a);
for b= 1:2:(2*r-1)
for p =1:a:r*a
AraPatient(p) = (b-r)*O1(p);
end
end
AraPatient
我希望在這裡AraPatient的結果是
[-2 -2 -2 0 0 0 2 2 2]
可是按下去之後的訊息是
Attempted to access O1(4); index out of bounds because numel(O1)=3.
這要怎麼改?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.54.170
※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1461090783.A.14B.html
→ celestialgod: p是1,4,7 O1長度只有3 04/20 09:38
→ ljuyentintho: 可是我本來就希望長度是3阿 04/20 20:33
→ celestialgod: 所以去處理O1的標記阿= = 04/20 20:35
推 sin55688: 你都知道錯誤的原因了,那應該不難改吧 04/20 20:36
→ celestialgod: 例如改成 O1((p-1)/3+1) 04/20 20:36
→ ljuyentintho: 喔喔我了解了 04/20 20:49
推 sunev: O1都是1,所以? 04/20 21:46
→ ljuyentintho: 已解決 謝啦 04/21 03:16