필터 지우기
필터 지우기

Values Stops Somewhere that it shouldn't

조회 수: 3 (최근 30일)
Atahan Celebi
Atahan Celebi 2018년 11월 14일
다시 열림: Walter Roberson 2018년 12월 29일
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
Atahan Celebi
Atahan Celebi 2018년 11월 14일
it gives error when I try
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에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by