matlab - 如何计算日出和日落时间(matlab)?

标签 matlab

我需要在 Matlab 中计算日出和日落时间,但我找不到正确(且简单)的方法来做到这一点。

我需要获得与以下位置相同的结果:

https://www.esrl.noaa.gov/gmd/grad/solcalc/http://sunrise-sunset.org/api

我已经尝试根据这些文章实现一个功能https://en.wikipedia.org/wiki/Sunrise_equationhttp://www.wikihow.com/Estimate-the-Time-of-Sunrise-or-Sunset但结果是错误的。 (也许我做错了什么)

我还在 Matlab 中开发了一个脚本,似乎更准确,但我仍然无法获得准确的日出和日落时间:

% Parameters definition
lat = -23.545570; % Latitude
lng = -46.704082; % Longitude
UTCoff = -3; % UTC offset
nDays = daysact('01-jan-2017',  '15-mar-2017'); % Number of days since 01/01

% Longitudinal correction
longCorr = 4*(lng - 15*UTCoff);

B = 360*(nDays - 81)/365; % I have no idea

% Equation of Time Correction
EoTCorr = 9.87*sind(2*B) - 7.53*cosd(B) - 1.5*sind(B);

% Solar correction
solarCorr = longCorr - EoTCorr;

% Solar declination
delta = asind(sind(23.45)*sind(360*(nDays - 81)/365));

sunrise = 12 - acosd(-tand(lat)*tand(delta))/15 - solarCorr/60;
sunset  = 12 + acosd(-tand(lat)*tand(delta))/15 - solarCorr/60;

sprintf('%2.0f:%2.0f:%2.0f\n', degrees2dms(sunrise))
sprintf('%2.0f:%2.0f:%2.0f\n', degrees2dms(sunset))

根据 ESRL,此函数在本应为 06:09 时为我提供了 05:51:25 的日出,在本应为 18:22 时为我提供了 18:02:21 的日落。 (美国国家海洋和大气局)。

函数是基于这个开发的:https://www.mathworks.com/matlabcentral/fileexchange/55509-sunrise-sunset/content/SunriseSunset.mlx

我可以做些什么来提高准确性并从 ESRL (NOAA) 获得相同的值?

最佳答案

你在这里把苹果和橙子混在一起了!

  • 您使用的公式是计算实际日出和日落(几何)。

  • NOAA website给出表观日出和日落。这些值已针对大气折射进行了校正!

the glossary to the NOAA website , 它是这样写的:

Due to atmospheric refraction, sunrise occurs shortly before the sun crosses above the horizon. Light from the sun is bent, or refracted, as it enters earth's atmosphere. See Apparent Sunrise Figure. This effect causes the apparent sunrise to be earlier than the actual sunrise. Similarly, apparent sunset occurs slightly later than actual sunset.

所以这正是您观察到的计算错误的影响。

如果你真的想计算明显的日出和日落,引用Solar Calculation Details来自 NOAA 本身或 this SO answer .但请注意:“……这很复杂!”

编辑:请参阅我的其他答案,了解在 MatLab 中计算明显日出和日落的精确函数

关于matlab - 如何计算日出和日落时间(matlab)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42934300/

相关文章:

c# - Matlab MCR 是否支持多核?

matlab - Softmax 回归的向量化实现

matlab - N周期移动斜率的矢量化方法

matlab - 如何从 FFT 获取调幅信号的相位角

c++ - 检查哪个网格元素在原始多边形内

algorithm - 如何使这个算法稳定

c# - 将图像作为参数从 C# 发送到 matlab 函数

matlab - matlab中NaN的准确值是多少?

python - NumPy中MATLAB的repmat相当于什么

matlab - 如何在图像中找到局部最大值