フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

"index exceeds matrix dimension" error

1 回表示 (過去 30 日間)
Kelil Mohammed
Kelil Mohammed 2018 年 5 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to calculate perimeter of a triangle formed by three anchor node a,b and c, in wireless sensor network. following is my code, any one help please how this error can be solved
function perim = perimeter(AB,AC,BC)
perim = AB+AC+BC; % perimeter of virtual triangle ABC which is formed by anchor node A,B and C. .
if neighboring_anchor_n>=3
gridmap=zeros(row_n,col_n);
grid_covered_flag=zeros(row_n,col_n);
for a=1:neighboring_anchor_n-2
for b=a+1:neighboring_anchor_n-1
for c=b+1:neighboring_anchor_n
neighboring_node_index=setdiff(find(neighbor_matrix(i,:)==1),neighboring_anchor_index([a b c]));
perim =sqrt(transpose((neighboring_anchor_n(1,1)-neighboring_anchor_n(2,1)).^2+(neighboring_anchor_n(1,2)-neighboring_anchor_n(2,2)).^2)+sqrt(transpose((neighboring_anchor_n(1,1)-neighboring_anchor_n(3,1)).^2+(neighboring_anchor_n(1,2)-neighboring_anchor_n(3,2)).^2)+sqrt(transpose((neighboring_anchor_n(2,1)-neighboring_anchor_n(3,1)).^2+(neighboring_anchor_n(2,2)-neighboring_anchor_n(3,2)).^2);
end
end
Thank you for your help in advance.
  4 件のコメント
Bob Thompson
Bob Thompson 2018 年 5 月 8 日
For future reference it's a bit easier if you paste the line itself, rather than the number, as many people post incomplete code, so your error message might say 'line 10' but it's actually line 6 of the posted code. I assume that is not the case here because you have posted a function, but for future reference.
James Tursa
James Tursa 2018 年 5 月 8 日
I don't see where neighboring_anchor or neighboring_anchor_index come from. What are they? What size are they? Is this a nested function?

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by