✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。
更多Matlab仿真内容点击👇
Matlab图像处理(进阶版)
路径规划(Matlab)
神经网络预测与分类(Matlab)
优化求解(Matlab)
语音处理(Matlab)
信号处理(Matlab)
车间调度(Matlab)
⛄一、龙格库塔算法简介
龙格-库塔算法是一种常微分方程的数值解法,可以提供更高精度的解法。它的基本思想是通过逐步逼近精确解来得到数值解。龙格-库塔算法可以构造任意高阶的公式,其中比较常用的是四阶龙格-库塔公式。该算法以定步长来展开,但步长的选择需要根据数据帧率等实际情况来确定。具体步骤是先以初始步长计算近似值,然后将步长减半,再次计算近似值,直到满足精度要求为止。
⛄二、部分源代码
function [a] = AccelHarmonic_AnelasticEarth(Mjd_UTC,r_Sun,r_Moon,r,E,UT1_UTC,TT_UTC,x_pole,y_pole)
global Cnm Snm AuxParam const
gm = 398600.4415e9; % [m3/s2]; GGM03C & GGM03S
r_ref = 6378.1363e3; % Earth’s radius [m]; GGM03C & GGM03S
C = Cnm;
S = Snm;
[lM, phiM, rM] = CalcPolarAngles(r_Moon);
[lS, phiS, rS] = CalcPolarAngles(r_Sun);
Mjd_UT1 = Mjd_UTC + UT1_UTC/86400;
Mjd_TT = Mjd_UTC + TT_UTC/86400;
T = (Mjd_TT-const.MJD_J2000)/36525;
T2 = TT;
T3 = T2T;
T4 = T3*T;
if (AuxParam.SolidEarthTides)
% Effect of Solid Earth Tides (anelastic Earth)
% For dC21 and dS21
% The coefficients we choose are in-phase(ip) amplitudes and out-of-phase amplitudes of the
% corrections for frequency dependence, and multipliers of the Delaunay variables
% Refer to Table 6.5a in IERS2010
coeff0 = […
% l l’ F D Om Amp® Amp(I)
2, 0, 2, 0, 2, -0.1, 0;
0, 0, 2, 2, 2, -0.1, 0;
1, 0, 2, 0, 1, -0.1, 0;
1, 0, 2, 0, 2, -0.7,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2, -0.1, 0;
-1, 0, -2, 0, -1, -0.1, 0;
];
% For dC20
% The nominal value k20 for the zonal tides is taken as 0.30190
% Refer to Table 6.5b in IERS2010
coeff1 = […
% l l’ F D Om Amp® Amp(I)
0, 0, 0, 0, 1, 16.6, -6.7;
0, 0, 0, 0, 2, -0.1, 0.1;
0, -1, 0, 0, 0, -1.2, 0.8;
0, 0, -2, 2, -2, -5.5, 4.3;
0, 0, -2, 2, -1, 0.1, -0.1;
0, -1, -2, 2, -2, -0.3, 0.2;
1, 0, 0, -2, 0, -0.3, 0.7;
-1, 0, 0, 0, -1, 0.1, -0.2;
-1, 0, 0, 0, 0, -1.2, 3.7;
-1, 0, 0, 0, 1, 0.1, -0.2;
1, 0, -2, 0, -2, 0.1, -0.2;
0, 0, 0, -2, 0, 0.0, 0.6;
-2, 0, 0, 0, 0, 0.0, 0.3;
0, 0, -2, 0, -2, 0.6, 6.3;
0, 0, -2, 0, -1, 0.2, 2.6;
0, 0, -2, 0, 0, 0.0, 0.2;
1, 0, -2, -2, -2, 0.1, 0.2;
-1, 0, -2, 0, -2, 0.4, 1.1;
-1, 0, -2, 0, -1, 0.2, 0.5;
0, 0, -2, -2, -2, 0.1, 0.2;
-2, 0, -2, 0, -2, 0.1, 0.1;
];
% For dC22 and dS22
% Refer to Table 6.5c in IERS2010
coeff2 = […
% l l’ F D Om Amp
1, 0, 2, 0, 2, -0.3;
0, 0, 2, 0, 2, -1.2;
];
% Mean arguments of luni-solar motion
%
% l mean anomaly of the Moon
% l' mean anomaly of the Sun
% F mean argument of latitude
% D mean longitude elongation of the Moon from the Sun
% Om mean longitude of the ascending node of the Moon
l = mod((485868.249036+1717915923.2178*T+31.8792*T2+0.051635*T3-0.00024470*T4),const.TURNAS)*const.DAS2R;
lp = mod((1287104.79305+129596581.0481*T-0.5532*T2+0.000136*T3-0.00001149*T4),const.TURNAS)*const.DAS2R;
F = mod((335779.526232+1739527262.8478*T-12.7512*T2-0.001037*T3+0.00000417*T4),const.TURNAS)*const.DAS2R;
D = mod((1072260.70369+1602961601.2090*T-6.3706*T2+0.006593*T3-0.00003169*T4),const.TURNAS)*const.DAS2R;
Om = mod((450160.398036-6962890.5431*T+7.4722*T2+0.007702*T3-0.00005939*T4),const.TURNAS)*const.DAS2R;
% STEP1 CORRECTIONS
[lgM, dlgM] = Legendre(2,2,phiM);
[lgS, dlgS] = Legendre(2,2,phiS);
dCnm20 = 0.30190/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,1)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,1) );
dCnm21 = 0.29830/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*cos(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*cos(lS) )...
-0.00144/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*sin(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*sin(lS) );
dSnm21 = 0.00144/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*cos(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*cos(lS) )...
+ 0.29830/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*sin(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*sin(lS) );
dCnm22 = 0.30102/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*cos(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*cos(2*lS) )...
-0.00130/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*sin(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*sin(2*lS) );
dSnm22 = 0.00130/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*cos(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*cos(2*lS) )...
+ 0.30102/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*sin(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*sin(2*lS) );
dCnm40 = -0.00089/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,1)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,1) );
dCnm41 = -0.00080/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*cos(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*cos(lS) );
dSnm41 = -0.00080/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,2)*sin(lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,2)*sin(lS) );
dCnm42 = -0.00057/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*cos(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*cos(2*lS) );
dSnm42 = -0.00057/5*( const.GM_Moon/gm*(r_ref/rM)^3*lgM(3,3)*sin(2*lM)...
+ const.GM_Sun/gm*(r_ref/rS)^3*lgS(3,3)*sin(2*lS) );
% STEP2 CORRECTIONS
dC20 = 0;
for i=1:21
theta_f = -coeff1(i,1:5)*[l lp F D Om]';
dC20 = dC20 + 1e-12*(coeff1(i,6)*cos(theta_f)-coeff1(i,7)*sin(theta_f));
end
dCnm20 = dCnm20 + dC20;
theta_g = iauGmst06(const.DJM0, Mjd_UT1, const.DJM0, Mjd_TT);
dC21 = 0;
dS21 = 0;
for i=1:48
theta_f = (theta_g+pi)-coeff0(i,1:5)*[l lp F D Om]';
dC21 = dC21 + 1e-12*(coeff0(i,6)*sin(theta_f)+coeff0(i,7)*cos(theta_f));
dS21 = dS21 + 1e-12*(coeff0(i,6)*cos(theta_f)-coeff0(i,7)*sin(theta_f));
end
dCnm21 = dCnm21 + dC21;
dSnm21 = dSnm21 + dS21;
dC22 = 0;
dS22 = 0;
for i=1:2
theta_f = 2*(theta_g+pi)-coeff2(i,1:5)*[l lp F D Om]';
dC22 = dC22 + 1e-12*coeff2(i,6)*cos(theta_f);
dS22 = dS22 - 1e-12*coeff2(i,6)*sin(theta_f);
end
dCnm22 = dCnm22 + dC22;
dSnm22 = dSnm22 + dS22;
% Treatment of the Permanent Tide (anelastic Earth)
dC20 = 4.4228e-8*(-0.31460)*0.30190;
% Here 4.173e-9 is added to C20 to convert it to a tide-free system;
% then, the permanent tide contribution is subtracted.
dCnm20 = dCnm20 + 4.173e-9 - dC20;
% Effect of Solid Earth Pole Tide (anelastic Earth)
dC21 = -1.348e-9*(x_pole+0.0112*y_pole);
dS21 = 1.348e-9*(y_pole-0.0112*x_pole);
dCnm21 = dCnm21 + dC21;
dSnm21 = dSnm21 + dS21;
C(3,1) = C(3,1) + dCnm20;
C(3,2) = C(3,2) + dCnm21;
C(3,3) = C(3,3) + dCnm22;
S(3,2) = S(3,2) + dSnm21;
S(3,3) = S(3,3) + dSnm22;
C(5,1) = C(5,1) + dCnm40;
C(5,2) = C(5,2) + dCnm41;
C(5,3) = C(5,3) + dCnm42;
S(5,2) = S(5,2) + dSnm41;
S(5,3) = S(5,3) + dSnm42;
end
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合