How to avoid for loops while storing cell indices of a Grid?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am working on an object tracking project in an automotive environment. I am creating a Grid in Matlab which rotates in every measurement frame according to yaw rate of the ego vehicle. So, for every frame, I have to store the indices of all the grid cells in an array so that I can use that array later to find out that which detections are lying in which cells. The piece of code that does this index storing work for me is:
cellIndicesCtr = 1;
for i=1:size(x2,1)-1
for j=1:size(x2,2)-1
cellsIndices_local{cellIndicesCtr,1} = [x2(i,j) x2(i,j+1) x2(i+1,j+1) x2(i+1,j) x2(i,j)];
cellsIndices_local{cellIndicesCtr,2} = [y2(i,j) y2(i,j+1) y2(i+1,j+1) y2(i+1,j) y2(i,j)];
cellIndicesCtr = cellIndicesCtr + 1;
end
end
x2 are y2 are the arrays with the x- and y-coordinates of the rotated grid respectively. My question is: Can I do this without using the for loops? Don't bother about the order in which I am storing the indices. That's for plotting purposes. I am just concerned with getting rid of for loops. Any help in this regard would be highly appreciated. Thanks!
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!