HOW TO CORRECT attempted to access x(1,3), index out of bounds because numel(x)=1.

2 views (last 30 days)
clc
clear all
x=0;
D=zeros(154);
for i=1:248
D(x(i,1),x(i,2))=x(i,3);
end
D1=D+D';
for i=1:154
for j=1:154
if D1(i,j)==0
D1(i,j)=inf;
end
end
end
for i=1:154
for j=1:154
if i==j
D1(i,j)=0;
end
end
end
I JUST WANNA KNOW HOW TO CORRECT.... I FEEL I WILL BE CRAYZY(wuwuwu)
  8 Comments
Cedric
Cedric on 1 May 2013
Edited: Cedric on 1 May 2013
As I said above: you should first switch to lower case when you write on the forum.
Then, how much time do you have for building this adjacency matrix? Is it for a homework, a longer term project, a Master/Ph.D. thesis?
EDIT: I'm off for the night; anyway, you want x to be a 248x3 array before the first FOR loop starts, not 0 as you defined it. Moreover, the first two columns of x must be positive integers below or equal to 154 (ID of vertices I guess).
Then, the rest should work, but the two nested FOR loop statements can be done way more efficiently (in one line each). We can talk about this, but you'll have to answer my question about the time frame and the nature of this work first.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!