フィルターのクリア

Index in position 2 exceeds array bounds (must not exceed 3).

1 回表示 (過去 30 日間)
Emily Browning
Emily Browning 2019 年 3 月 17 日
回答済み: Walter Roberson 2019 年 3 月 17 日
When calculating C (bolded) I get the following error "Index in position 2 exceeds array bounds (must not exceed 3)."
CXYZ=[166 64 64 0 0 0; 64 166 64 0 0 0; 64 64 166 0 0 0;0 0 0 80 0 0; 0 0 0 0 80 0; 0 0 0 0 0 80];
l(1,1) = 1;
l(1,2) = 0 ;
l(1,3) = 0;
l(2,1) = 0;
l(2,2) =1/sqrt(2);
l(2,3) =1/sqrt(2);
l(3,1) =0 ;
l(3,2)= -1/sqrt(2);
l(3,3) =1/sqrt(2);
g= [1, 2, 3, 4]
a=1
for (i = g)
for (j= g)
for(k=g)
for (p=g)
C(a) = l(1,i).*l(1,j).*l(1,k).*l(1,p).*CXYZ(1,1); % bolded
a= a+1;
end
end
end
end

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 17 日
Because g includes 4, at some point you are going to try to access l(1,4) . However you only initialize l to (3,3) so l(4,:) and l(:,4) do not exist

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by