✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
由于地球的倾斜和围绕太阳的轨道的偏心率,太阳在天空中的轨迹取决于一年中的时间和观测的纬度。 “analemma”是由地球轨道与太阳的偏心率和倾斜引起的现象。如果您设置相机并在一年中每隔 24 小时拍摄一次太阳照片,天空中就会出现一个“无限大”的符号。八字形表示“表观太阳时”(正午 = 太阳直接在头顶)与“平均太阳时”(时钟计算 24 小时天)之间的差异。
⛄ 部分代码
function [azimuthAngle,elevationAngle] = sunPosition(dayOfYear, ...
timeHour,latitude)
% Copyright 2016 The MathWorks, Inc.
% Make sure time vector is oriented properly
if size(timeHour,1) == 1 && size(timeHour,2) > 1
timeHour = timeHour';
end
% Make sure day vector is oriented properly
if size(dayOfYear,2) == 1 && size(dayOfYear,1) > 1
dayOfYear = dayOfYear';
end
% Account for Multiple Days
numTime = numel(timeHour);
numDays = numel(dayOfYear);
timeHour = repmat(timeHour,1,numDays);
% Shift solar noon for longitude
longitudeShift = 0;
% Equation of Time - East/West timeshift associated with elliptical orbit
equationTime = 9.87*sind(2*360/365*(dayOfYear-81)) - ...
7.53*cosd(360/365*(dayOfYear-81)) - ...
1.5*sind(360/365*(dayOfYear-81));
solarTimeCorrection = equationTime/60 + longitudeShift/15;
solarTime = timeHour + repmat(solarTimeCorrection,numTime,1);
% Angle of Sun - Related to Solar time (0 deg - vertical sun)
hourAngle = 180*(12-solarTime)/12;
% Sun Declination - varies from +/- 23.45 during year
sunDeclinationAngle = 23.45*sind(360/365*(dayOfYear-81));
% Solar Zenith Angle Calculations
cosineZenith = bsxfun(@plus,sind(latitude)*sind(sunDeclinationAngle),...
cosd(latitude)*bsxfun(@times,cosd(sunDeclinationAngle),cosd(hourAngle)));
zenithAngle = acosd(cosineZenith);
elevationAngle = 90 - zenithAngle;
% sunUp = elevationAngle > 0;
% Solar Azimuth Angle Calculations
eastVertical = bsxfun(@times,cosd(sunDeclinationAngle),sind(hourAngle));
southVertical = bsxfun(@plus,-sind(sunDeclinationAngle)*cosd(latitude), ...
bsxfun(@times,cosd(sunDeclinationAngle),sind(latitude)*cosd(hourAngle)));
posAngle = eastVertical > 0;
azimuthAngle = zeros(numTime,numDays);
azimuthAngle(posAngle) = acosd(-southVertical(posAngle)./ ...
sqrt(eastVertical(posAngle).^2 + southVertical(posAngle).^2));
azimuthAngle(~posAngle) = 180 + acosd(southVertical(~posAngle)./ ...
sqrt(eastVertical(~posAngle).^2+southVertical(~posAngle).^2));
azimuthAngle = -azimuthAngle;
end
⛄ 运行结果
编辑
⛄ 参考文献
❤️ 关注我领取海量matlab电子书和数学建模资料
❤️部分理论引用网络文献,若有侵权联系博主删除