Sort computations into groups in for loop
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey guys, I was wondering if there is a way to group computations in a for loop. For example i have N set of training vectors, each vector has 2 values(2_Dimensional). All these vectors need to be subtracted from the two reconstruction vectors to find the distance between either reconstruction level. This is what I want, once the for loop computes the distance between both points, group that value into a group which consists of values that are all close to their respective reconstruction level. Thanks
댓글 수: 0
답변 (1개)
Image Analyst
2013년 5월 5일
Sure. Assuming all your training vectors are in rows of a 2D array, did you try something like this
for k = 1 : n
% Extract the k'th training vector from the list of all of them.
thisTrainingVector = allTrainingVectors(k, :); % Extract row
% Get difference between this vector and the first "reconstruction vector".
diff1 = thisTrainingVector - reconstructionVector1;
% Get difference between this vector and the second "reconstruction vector".
diff2 = thisTrainingVector - reconstructionVector2;
% Then do whatever you need to do with diff1 and diff2.
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!