Info
This question is closed. Reopen it to edit or answer.
Index exceeds matrix dimensions, error problem
1 view (last 30 days)
Show older comments
When I run this code, where no. of rows in l is 1 less than that of p. Can someone find the problem as i am not able to! Thanks in advance
% code
[n,~]=size(p);
area=zeros(n,1);
if n>2
for z=2:n-1
ls=l(z-1:z,:);
ps=p(z-1:z+1,:);
rms=[p(z,6):-5:minr,minr];
i=size(rms);
aream=1e+137;
for ii=1:i
rm=[0;rms(ii);0];
disp(num2str(rms(ii)))
fitting_curve(ls,ps,rm,w)
obstacle=splitPolygons(obs);
for o=1:1:N
obst = transpose(cell2mat(obstacle(o)));
area(ii) = area(ii)+area_intersection(curve,road,obst);
end
if area(ii)<aream
aream=area(ii);
p(z,9)=rms(ii);
end
end
end
end
It shows following error
% code
Index exceeds matrix dimensions.
Error in minrad (line 8) ls=l(z-1:z,:);
0 Comments
Answers (1)
Walter Roberson
on 21 Jun 2015
You are failing while indexing ls, an array whose size we have no information about. We do not know that it has at least as many rows as p has (or perhaps one fewer)
2 Comments
Torsten
on 22 Jun 2015
The solution is to check whether the matrix l has at least (n-1) rows.
If not, you will receive the above error message.
Best wishes
Torsten.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!