please help with Matlab on Problem 11: (8 points) In the following problem, x is
ID: 3665012 • Letter: P
Question
please help with Matlab
Explanation / Answer
Vectorized implementation for computing the euclidean distance is significantly faster than PDIST2
D = sqrt( bsxfun(@plus,sum(A.^2,2),sum(B.^2,2)') - 2*(A*B') );
It is based on the fact that: ||u-v||^2 = ||u||^2 + ||v||^2 - 2*u.v
Matlab function to calculate total distance travelled moving through points is as:
total_dist = 0;
for i = 1:length(path)-1
total_dist = total_dist + distances(path(i),path(i+1));
end
total_dist = total_dist + distances(path(end),path(1));
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.