What's the syntax for plotting a few celestial lines?

3 Ansichten (letzte 30 Tage)
Lucius
Lucius am 1 Aug. 2015
Beantwortet: Star Strider am 1 Aug. 2015
I need a graph of containing the galactic equator and ecliptic with two border lines each converted into right ascension and declination axes. Borders of +-20° for the galactic equator and +-12° for the ecliptic. What would be the syntax for such an easy graph?

Antworten (1)

Star Strider
Star Strider am 1 Aug. 2015

This plots the celestial equator and ecliptic. I don’t understand how you want the borders plotted, so I leave that to you. Those would likely involve some trigonometric calculations to produce additional offset copies of the cylinder plot for each border. Note how I created the circles for the ecliptic and celestial equator from the cylinder function, and then used the rotate function to incline the Earth, its axis, and celestial equator.

This should get you started. Experiment to get the result you want.

The code:

N = 20;                                                                 % Number Of Faces On Sphere
[Xs,Ys,Zs] = sphere(N);
axvct = linspace(-1.5, 1.5, N)';
axline = [zeros(N,1) zeros(N,1), axvct];
[Xc, Yc, Zc] = cylinder(1.5,N);
figure(1)
Sh = surf(Xs, Ys, Zs);                                                  % Plot Sphere
hold on
Lh = plot3(axline(:,1), axline(:,2), axline(:,3), 'r', 'LineWidth',2)   % Plot Sphere Axis
Ec = surf(Xc,Yc,[Zc(1,:)+0.025; Zc(1,:)-0.025])                         % Ecliptic
Ce = surf(Xc,Yc,[Zc(1,:)+0.025; Zc(1,:)-0.025])                         % Celestial Equator
hold off
shading flat
axis equal
rotate(Sh, [1 1 0], 23.4)                                                 % Rotate Sphere
rotate(Lh, [1 1 0], 23.4)                                                 % Rotate Sphere Axis
rotate(Ce, [1 1 0], 23.4)   
xlabel('X')
ylabel('Y')
zlabel('Z')

The plot:

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by