Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

"index exceeds matrix dimension" error

1 vue (au cours des 30 derniers jours)
Kelil Mohammed
Kelil Mohammed le 8 Mai 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
Bob Thompson
Bob Thompson le 8 Mai 2018
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 le 8 Mai 2018
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?

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by