Getting an 'Array indices must be positive integers or logical values' error
이전 댓글 표시
In the given code, waypoints is a 3x3 matrix. The error comes in line 8.
persistent waypoints0 traj_time d0
if nargin > 2
d = waypoints(:,2:end) - waypoints(:,1:end-1);
d0 = 2 * sqrt(d(1,:).^2 + d(2,:).^2 + d(3,:).^2);
traj_time = [0, cumsum(d0)];
waypoints0 = waypoints;
else
if t >= traj_time(end)
t = traj_time(end);
end
t_index = find(traj_time > t,1) - 1;
if (t_index == 0)
t_index = 1;
end
if(t == 0)
desired_state.pos = waypoints0(:,1);
else
scale = (t-traj_time(t_index)) / d0(t_index);
index = [(t_index-1)*8+1:t_index*8];
end
end
댓글 수: 4
KALYAN ACHARJYA
2019년 9월 17일
편집: KALYAN ACHARJYA
2019년 9월 17일
Can you share the detail of other variables also, so that we can try on it?
Aquatris
2019년 9월 17일
Which line is line 8?
Guillaume
2019년 9월 17일
We really need the function line that this code goes into. The full text of the error message would be extremely useful as well. Also, tell us if it's when the persistent variables are initialised (i.e. nargin > 2) or when it's using them (nargin <= 2).
It's also not clear what the 3rd input would be. I can see just one input needed for initialisation (waypoints) and one input needed afterward (t).
Orpheus
2019년 9월 17일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!