Measuring distance using "pdist()"
Show older comments
Hi, I am relatively new to Matlab, and I have a question regarding the function pdist(), I have a following code:
% RA Dec
A = [00 08.2 +29 04
12 54.0 +56 00
12 55.4 +3 25
17 58.8 -9 46
18 05.6 -30 25
23 03.7 +28 04
23 04.6 +15 11
23 39.3 +77 36];
Ar = [A(:,1)+A(:,2)/60 A(:,3)+A(:,4)/60];
[X,Y,Z] = sphere;
[RAx,DCy,Zz] = sph2cart((Ar(:,1)*2*pi), Ar(:,2)*pi/180, ones(size(Ar,1)));
figure(1)
hm = mesh(X,Y,Z);
hold on
plot3(RAx, DCy, Zz, 'h', 'MarkerSize',5, 'MarkerFaceColor','b')
hold off
axis equal off
set(hm, 'EdgeColor', 'k', 'FaceAlpha',0.5)
view(55,20)
distance = pdist(Ar,'euclidean');
Z = squareform(distance);
basically A is the right ascension and declination of a particular star, and I used the pdist(Ar,'euclidean') to obtain the distance between any 2 points.
The question is: Does the distance obtained by "pdist" equal to the distance between 2 points on a sphere or is it on a 2D plane?
Accepted Answer
More Answers (0)
Categories
Find more on Bar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!