Values Stops Somewhere that it shouldn't

1 次查看(过去 30 天)
I have 365 (days) input for my graphic but in somewhere it is stop making graphics
It is my graphic result
abc.png
Here, original graphic that I should get :
abc2.png
My whole code:
days = 1:365;
%Formulas of the Equation of Time
earth_tilt = -7.655*sin(2*pi*days/365)
elliptical_orbit = 9.873*sin(4*pi*days/365+3.588)
time_variation = earth_tilt + elliptical_orbit
plot(days,earth_tilt,'g--')
hold on
plot(days,elliptical_orbit,'r-.')
plot(days,time_variation,'black')
ax = gca;
ax.XAxisLocation = 'origin';
ax.XAxis.TickLabels = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}';
ax.XAxis.Limits = [0 500];
title('Time Variation')
xlabel('Day of The Year','FontWeight','bold')
ylabel('Minutes','FontWeight','bold')
legend({'Earth Elliptic Orbit','Tilt of Earth Axis','Orbit+Tilt'},'FontSize',14)
% Location information of legend
set(legend, 'Location', 'NorthWest')

采纳的回答

possibility
possibility 2018-11-14
编辑:possibility 2018-11-14
Hi Atahan,
Your graph doesn't stop in the middle. The figure is the same with the original. Your months labeling is wrong. Change the axis limits from
ax.XAxis.Limits = [0 500];
to
ax.XAxis.Limits = [0 360];
I think this would resolve the problem.
Selamlar :)
--- edit -------
Although your graph is now scaled properly, your labeling for months is still wrong. In order to correct it, one way could be using text commands instead of modifying the xaxis. The code is as follows:
days = 1:365;
%Formulas of the Equation of Time
earth_tilt = -7.655*sin(2*pi*days/365);
elliptical_orbit = 9.873*sin(4*pi*days/365+3.588);
time_variation = earth_tilt + elliptical_orbit;
plot(days,earth_tilt,'g--')
hold on
plot(days,elliptical_orbit,'r-.')
plot(days,time_variation,'black')
%deleted part
%ax = gca;
%ax.XAxisLocation = 'origin';
%ax.XAxis.TickLabels = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}';
%ax.XAxis.Limits = [0 500];
%added part
axis([0 370 -20 20]);
months={'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
for i=1:length(months)
text(15+(i-1)*30,-19,months(i));
end
%rest
title('Time Variation')
xlabel('Day of The Year','FontWeight','bold')
ylabel('Minutes','FontWeight','bold')
legend({'Earth Elliptic Orbit','Tilt of Earth Axis','Orbit+Tilt'},'FontSize',14)
% Location information of legend
set(legend, 'Location', 'NorthWest')
  2 个评论
possibility
possibility 2018-11-14
I corrected.
Your labeling seems still wrong though. Let us work on it. I will edit my main comment.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geology 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by