Can't get Orekit to work in Matlab

Don’t know if this all of it but on the lines:
DM = org.orekit.data.DataProvidersManager.getInstance();
crawler = org.orekit.data.DirectoryCrawler(File([cd ,’\OrekitData’]));

You need to change the ‘\OrekitData’ to match your directory ‘\orekit-data’
See if that helps

Thank you, I miss that. I’m trying with other functions like Vectors3D, and the same error appears. It seems like it’s not importing libraries because every function is undefined, I don’t know. Is there any way I can check that?

I will have to do some further digging and get back to you

Thank you very much
If I can make it work, I’ll update the message

Hi David and Stephen,

David, I have just a quick question. Is your Java version at least equal to 8?

Indeed, if your Java version is below 8, you can’t run Orekit.

Best regards,
Bryan

Please find below a link explaining how to verify your Java version in Matlab and how to configure a new Java version.

https://www.mathworks.com/help/compiler_sdk/java/configure-your-java-environment.html

You can also try to read this topic on the forum: First step with matlab - #4 by Tintin

Bryan

Issue solved. Script by @bcazabonne works perfectly.
Thank you very much for your time and help.

Hi all.

I’ve run into some issues running @StephenC 's .m file with the new version(s) of Orekit (v11.1) and Matlab (R2021b). I updated the Matlab Java version to 8 and mapped all of the directories and files properly, but still was getting error messages. Eventually, I figured out from the javadoc that there have been some changes since upgrading from 10.1 to 11.1 that throw errors for some of the method calls. The attached .m file seems to be sufficient to get orekit up and running in Matlab for Orekit v11.1 with Hipparchus v2.0.
orekitStartup.m (2.3 KB)

Note that the KeplerianPropagator no longer has a setSlaveMode method. I “fixed” this by simply removing the statement. Not sure what the effects might be.

I still get an error in @StephenC 's file when trying to run “periodMin = periodKm(sma_m/1000.0);” but I don’t think that is an Orekit issue… Still working my way through this example to get it all running.

A question for Matlab users: Has anyone figured out how to get autocompletion for the java methods/classes/etc to work? It’s a pain to constantly refer back to the javadoc.

1 Like

Did you find any issues with the approach you listed here? Did the removed statement have any issues?

Hi, Krazylvan

The function “periodKm” maybe be writen by Stephen, not a class in Orekit, because I can’t find it in Eclipse.

Hi all
I think I have made it successfully to connect between matlab and Orekit, and run basic code faultlessly.
However, when the code "earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2003,true);
" was run in matlab, there are some exception occurred.
That is

org.orekit.errors.OrekitException: unable to find
file
/assets/org/orekit/IERS-conventions/2003/nutation-arguments.txt

Actually, I find that the file is in the path of “resource\assets\org\orkit\IERS-conventions\2003.”
image

So, what should I do to solve thie question?

Hi,

Maybe you configured the wrong path to access these data?
The configuration of this path is done at the beginning of the code when initializing the data context.
Could you check it?

Best regards,
Bryan

It can’t be a path problem, the file not found must be part of the resources that are in the Orekit jar.

This problem has been solved. Previous Orekit jar was exported through Eclipse by myself, maybe something went wrong. Well, I load the file of “orekit-11.2.1.jar” and add it to matlab classpath. Then all code run successfully.
Thanks a lot. :grinning:

Hi, Orekit developers
How to write the matlab code according to Java language of:
"
final Collection(DSSTForceModel> forces = new ArrayList(DSSTForceModel>();
forces.add(zonal);
forces.add(tesseral);
"
It’s different in matlab, right?

Hi,

You could try something like

import java.util.ArrayList;
forces = ArrayList;
forces.add(zonal);
forces.add(tesseral);

If you want to add these force models to the propagator, I recommend you to use directly .addForceModel(...) method of the propagator.

propagator.addForceModel(zonal);
propagator.addForceModel(tesseral);

Bryan

Well,this answer is very useful for me. :laughing:

I had trouble piecing together everything and getting it updated to current Orekit (12.0.1), so I’ve created Set up Orekit in Matlab ($3643444) · Snippets · GitLab, which I hope will help others coming to this thread.

1 Like

Hi all,

I am new to working with Orekit using Matlab and I am encountering some issues that I am not able to solve, even with the explanations provided above.

I am attempting to execute the first example provided in Orekit’s API (Orekit Tutorials – Propagation), but Matlab is encountering errors that I do not understand. I believe that the locations of the Java and Orekit files are correct on my computer.

Having said that, one of the errors that Matlab is encountering is in the following lines:

’ import org.orekit.time.TimeScalesFactory
utc = TimeScalesFactory.getUTC();’

The error is:

'Error using orbita_basica_propagacion (line 19)
Java exception occurred:
org.orekit.errors.OrekitException: Historical IERSD UTC-TAI
data not loaded
at
org.orekit.time.LazyLoadedTimeScales.getUTC(LazyLoadedTimeScales.java:188)

at
org.orekit.time.TimeScalesFactory.getUTC(TimeScalesFactory.java:130)’

I appreciate your assistance with this.

Juanlu"

Hi @Juan_Luis

You have this error because the orekit-data were not loaded.
Did you downloaded the orekit-data? (Orekit / Orekit Data · GitLab)

Also, the tutorial doesn’t explain how to initialize them. Could you try to add the following lines:

DM=org.orekit.data.DataContext.getDefault().getDataProvidersManager(); %Works for v11.1
crawler = org.orekit.data.DirectoryCrawler(File(['c:\Your\Path\To\The\Unzipped\orekit-data-master\']));
DM.clearProviders()
DM.addProvider(crawler)