Index of element to remove exceeds matrix dimensions.ERROR

global ASOption
Nodes(:,1)=[];
NewNodes(1,:)=[];
Distances=zeros(ASOption.n,ASOption.n);
PI=3.141592
for i=2:ASOption.n
for j=1:i
if(i==j)
continue;
else
deg1=round(Nodes(i,:));
minimum1=(Nodes(i,:))-deg;
NewNodes(i,:)=PI*(deg1+5.0*minimum1/3.0)/180.0;
deg2=round(Nodes(j,:));
minimum2=(Nodes(j,:))-deg2;
NewNodes(j,:)=PI*(deg2+5.0*minimum2/3.0)/180.0;
dij=stdist(NewNodes(i,:),NewNodes(j,:));
Distances(i,j)=dij
Distances(j,i)=Distances(i,j);
end
end
end
I am trying to caculate geographical distance between nodes gives in the node matrix. but i get ??? Index of element to remove exceeds matrix dimensions.ERROR.....please help...

1 Comment

Which line does it give that message for?
The only place you remove elements are on the second and third line, and the only way the elements you are asking to remove there might not exist is if the matrix is already empty (in which case one or both of its dimensions might be 0, so index 1 might not exist.)

Sign in to comment.

Answers (1)

Run the code below you will see the exact error message. It's because variable Nodes and NewNodes didn't even exist before you were trying to remove their elements.
clear all;
Nodes(:,1)=[];
NewNodes(1,:)=[];
??? Index of element to remove exceeds matrix dimensions.
Nodes seems to be an input of the script above. You need to provide value for it.

1 Comment

input_signals(1:5,:) = [] ??? Index of element to remove exceeds matrix dimensions.

Sign in to comment.

Asked:

on 17 Sep 2011

Commented:

on 30 Nov 2016

Community Treasure Hunt

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

Start Hunting!