Luigi De Maria (2021). Earth Magnetic Field with IGRF 13th Gen. (https://www.mathworks.com/matlabcentral/fileexchange/88406-earth-magnetic-field-with-igrf-13th-gen), MATLAB Central File Exchange. Retrieved .
Yes, there was an error in that specific location! Thank you very much for the feedback, I will immediately upload an updated version!
Let me know if there are any other issue!
In this line:
d_P_nm(i,j) = cos(theta)*d_P_nm(i,j-1) - ...
sin(theta)*d_P_nm(i,j-1) - K_nm(i,j)*d_P_nm(i,j-2);
I believe it should be sin(theta)*P_nm instead of d_P_nm.
According to equation 19c from (https://hanspeterschaub.info/Papers/UnderGradStudents/MagneticField.pdf).
I'm not sure if this fixes the entire program but this is just an error that I had noticed.
I am currently working on the IGRF-13 from a project in C too. I am getting correct results for the B_r and B_phi components but I am currently stuck on computing the Legendre polynomial derivative too for determining the B_theta component. Let me know if you figure that part out.
Mr. Brown may you tell me the line you are referring to? Do you mean the else in the normalization of the K_nm coefficients?
There seems to be an error in the formula used for the recurrence relation in finding the derivatives of the legendre polynomials (inside the second else condition)
Thank you for the review Arthur! I have really appreciated your comparison!
I will investigate the nature of those differences and update the code as soon as I have some free time to dedicate.
I have made a comparison, the link should work now:
The function is similar but is not exactly right. I've use the correct gh coefficient interpolated at the right time, not the one provided in IGRF-13 as you only have year 2020 available.
The function is very efficient however:
IGRF-13-DeMaria ... 182.010 ms
IGRF-12-Matlab ... 34145.792 ms (igrfmagm)
IGRF-13-Compston ... 753.822 ms (gh vector pre-allocated)
This is the orbit I am using:
Initial datetime: 20-Sep-2008 11:01:18
Data generated using Matlab 2020a
Yes I tested it during a project development. However I did not compared it with Matlab igrfmagm, I will do so in the next days. Thank you for the feedback!
P.S. The image you linked results as "not found"
The function execution is really good, however the output doesn't match at all with igrfmagm matlab built-in function (Matlab 2020a). See image link below.
I don't have access to Matlab 2020b with 13th model at the moment, did you benchmark your code against igrfmagm?
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!