I wish to measure the distance of points from the origin(0,0). Based on this question Wrong setting of pdist input data - Matlab I used a loop but I wonder is there another way?
Script:
clc;
clear all;
x1 = [1:11];
y1 = [1;1;11;16;19;3;14;5;16;10;22];
x2 = [0];
y2 = [0];
for i = 1:length(x1)
dX = [x1(i),y1(i); x2, y2]
distResult = pdist(dX,'euclidean')
end
pdist2
. No loop required. – beakerpdist2([x2, y2], [x1.', y1])
– beaker