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

1 view (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
HOW IT HAPPEND= = AND I WANNA KNOW HOW TO CORRECT.DO ME A FAVOR I WILL APPRECIATE FORERVER,BECAUSE THE CODE CONNECTS WITH ONE IMPORTANT TEST.HELP!!!
  7 Comments

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 30 Apr 2013
Because you set x to 0, which means its length is 1, you can not use
x(i,1)
with i>1

Community Treasure Hunt

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

Start Hunting!