Reputation: 913
I'm loading a .csv file to do a few calculations in matlab. The file itself has ~1600 lines, but I'm interested in only a subset.
load file.csv; %load file
for i = 400:1200 %rows I am interested in
rh_x= file(i,60); % columns interested, in column 60 for the x, 61 for y
rh_y= file(i,61);
rh_x2 = file(i+1, 60); % next point (x,y)
rh_y2 = file(i+1, 61);
p1 = [rh_x, rh_y];
p2 = [rh_x2, rh_y2];
coord = [p1, p2];
Distan = pdist(coord, 'euclidean'); ****
disp(Distan);
end
Nothing is being stored in my Distan variable (distance formula), where I tried to input two points. Why is that the case? I'm just wanting to calculate the distance formula for all the pairs of points in rows 60 and 61 for frames 400-1200.
Thank you.
Upvotes: 0
Views: 290
Reputation: 2276
Change your coord
assignment to the following:
coord = [p1; p2];
The way you have it, it is storing all of the x, y pairs on the same row, as a 1x4 matrix. The above method stores it as a 2x2 matrix and pdist
gives an answer.
Upvotes: 2