MATLAB attempted to access x(1,3), index out of bounds because numel(x)=1.
1 view (last 30 days)
Show older comments
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
Walter Roberson
on 1 May 2013
Duplicates by later http://www.mathworks.co.uk/matlabcentral/answers/74170-how-to-correct-attempted-to-access-x-1-3-index-out-of-bounds-because-numel-x-1 which also has discussion. Discussion should continue here instead of there.
Answers (1)
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
3 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!