MATLAB: Loading a set of data from a txt file, plotting the data onto a spherical 3D plot (astronothe)

3d graphastronomyloading .txt filespherical plot

Hi, I am trying to import some star data in the form of a .txt file (notepad) which has a column of Right Ascension, and a second column of Declination. Here is an example:
RA DEC
00 08.2 +29 04
00 09.0 +59 08
00 13.1 +15 10
00 25.4 -77 17
00 26.2 -42 20
Then I am to plot the coordinates onto a spherical 3D graph (celestial sphere), I am new to matlab and I need some assistance on this, any help is appreciated. Please be gentle on the comments. Thank you =)

Best Answer

See if this works:
% RA DEC
A = [00 08.2 +29 04
00 13.1 +15 10
00 25.4 -77 17
00 26.2 -42 20];
Ar = [A(:,1)+A(:,2)/60 A(:,3)+A(:,4)/60]; % Convert To Decimal Degrees
[X,Y,Z] = sphere; % Get Sphere Coordinates
[RAx,DCy,Zz] = sph2cart(Ar(:,1)*pi/180, Ar(:,2)*pi/180, ones(size(Ar,1))); % Convert To Cartesian (Radius = 1)
figure(1)
hm = mesh(X,Y,Z);
hold on
plot3(RAx, DCy, Zz, 'bp', 'MarkerSize',15, 'MarkerFaceColor','b')
hold off
axis equal
set(hm, 'EdgeColor', 'k', 'FaceAlpha',0.5)
view(55,20)
Experiment to get the result you want.