Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

"index exceeds matrix dimension" error

1 visualizzazione (ultimi 30 giorni)
Kelil Mohammed
Kelil Mohammed il 8 Mag 2018
Chiuso: MATLAB Answer Bot il 20 Ago 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 Commenti
Bob Thompson
Bob Thompson il 8 Mag 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 il 8 Mag 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?

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by