Clear Filters
Clear Filters

How do I color my orbits based off of Jacobi Constant?

4 views (last 30 days)
This is what I want my plot to look like:
This is what my plot looks like:
This is my plot code with Jacobi Constant vector:
figure(1), color_map = jet(15);
grid on, hold on,
for ii = 1:15
plot(x(:, 1), x(:, 2), 'Color', color_map(ii, :), 'Linewidth', 1),
xlabel('x, NDU'), ylabel('y, NDU'),
plot(L(1, 1), 0, 'k.', 'MarkerSize', 20),
text(L(1, 1) + 0.013, 0, 'L1', 'Color', 'k'),
plot(L(2, 1), 0, 'k.', 'MarkerSize', 20),
text(L(2, 1) + 0.013, 0, 'L2', 'Color', 'k'),
plot(L(3, 1), 0, 'k.', 'MarkerSize', 20),
text(L(3, 1) + 0.005062645806268, 0, 'L3', 'Color', 'k'),
plot(L(4, 1), L(4, 2), 'k', 'Markersize', 20),
text(L(4, 1) - 0.05, L(4, 2) + 0.05, 'L_4', 'Color', 'k'),
plot(L(5, 1), L(5, 2), 'k', 'Markersize', 20),
text(L(5, 1) - 0.05, L(5, 2) - 0.05, 'L_5', 'Color', 'k'),
plot(1 - mu, 0, 'k.', 'MarkerSize', 20),
text(1 - mu + 0.013, 0, 'Moon', 'Color', 'k'),
plot(-mu, 0, 'k.', 'MarkerSize', 20),
text(-mu + 0.02, 0, 'Earth', 'Color', 'k'),
end
colorbar
C =
3.007676099413564
2.994200622706611
2.971545695246074
2.939417270410701
2.897381208873815
2.844828980359512
2.780923329169862
2.704511298825675
2.613980216377739
2.507005968545220
2.380077662128345
2.227495703195107
2.038881730418720
1.791003662001313
1.396075232221978
My central problem is that the Jacobi Constant values are not integers and I am not sure how to associate each value with a color to plot. This code has many support functions and I did not add them here. Hopefully this is enough to answer the question.

Accepted Answer

Star Strider
Star Strider on 7 Feb 2024
I would use the surf function with your matrix, with 'EdgeColor','interp' and then view(0,90). The contour (and contourf) funcitons are not designed to do the sort of plot you want. You might also consider using the daspect function.

More Answers (0)

Categories

Find more on Matrix Computations in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!