find Euclidean distance without the for loop

I was finding the Euclidean distance using the for loop, I need help finding distance without for loop, and store into an array.
i'm storing the value in distance1 and distance2 variable. I need to convert it into an array.

Answers (1)

Andrei Bobrov
Andrei Bobrov on 18 Jan 2019
Edited: Andrei Bobrov on 18 Jan 2019
distance12 = sqrt(sum(([centroid1,centroid2] - permute(dataset,[1,3,2])).^2,3));

Tags

Asked:

on 18 Jan 2019

Edited:

on 18 Jan 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!