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
Here, original graphic that I should get :
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')
0 件のコメント
採用された回答
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
2018 年 11 月 14 日
I corrected.
Your labeling seems still wrong though. Let us work on it. I will edit my main comment.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!