First step with matlab


This post was flagged by the community and is temporarily hidden.



There used to be a small example on the previous orekit wiki but cannot find that page now. I do not have a matlab license anymore but this below is the example that at some point was on the wiki. At least is shows how the library is interfaced.


% /* Copyright 2002-2018 CS Systèmes d'Information
%  * Licensed to CS Systèmes d'Information (CS) under one or more
%  * contributor license agreements.  See the NOTICE file distributed with
%  * this work for additional information regarding copyright ownership.
%  * CS licenses this file to You under the Apache License, Version 2.0
%  * (the "License"); you may not use this file except in compliance with
%  * the License.  You may obtain a copy of the License at
%  *
%  *
%  *
%  * Unless required by applicable law or agreed to in writing, software
%  * distributed under the License is distributed on an "AS IS" BASIS,
%  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%  * See the License for the specific language governing permissions and
%  * limitations under the License.
%  */
% Translated from to Matlab by Petrus Hyvönen 2011 as an
% example of how to access orekit from matlab
% the jars orekit-8.0.jar, hipparchus-core-1.0.jar, hipparchus-geometry-1.0.jar,
% hipparchus-ode-1.0.jar, hipparchus-fitting-1.0.jar, hipparchus-optim-1.0.jar
% and is in current matlab dir.

% These seems to work if pasted to prompt.
javaaddpath 'C:\ ... enter your path here ...\MATLAB'
javaaddpath 'C:\.. enter your path here ...\MATLAB\orekit-8.0.jar'
javaaddpath 'C:\.. enter your path here ...\\MATLAB\hipparchus-core-1.0.jar
javaaddpath 'C:\.. enter your path here ...\\MATLAB\hipparchus-geometry-1.0.jar
javaaddpath 'C:\.. enter your path here ...\\MATLAB\hipparchus-ode-1.0.jar
javaaddpath 'C:\.. enter your path here ...\\MATLAB\hipparchus-fitting-1.0.jar
javaaddpath 'C:\.. enter your path here ...\\MATLAB\hipparchus-optim-1.0.jar

%% do the imports
import org.orekit.errors.OrekitException
import org.orekit.frames.Frame
import org.orekit.frames.FramesFactory
import org.orekit.orbits.KeplerianOrbit
import org.orekit.orbits.Orbit
import org.orekit.orbits.PositionAngle
import org.orekit.propagation.SpacecraftState
import org.orekit.propagation.analytical.KeplerianPropagator
import org.orekit.time.AbsoluteDate
import org.orekit.time.TimeScalesFactory

%% Configure Orekit. The file must be in current dir'')

%% Initial orbit parameters
a = 24396159;    % semi major axis in meters
e = 0.72831215;  % eccentricity
i = (7.0)/180*pi; % inclination
omega = (180)/180*pi; % perigee argument
raan = (261)/180*pi; %right ascension of ascending node
lM = 0.0; % mean anomaly

%% Set inertial frame
inertialFrame = FramesFactory.getEME2000()

%% Initial date in UTC time scale
utc = TimeScalesFactory.getUTC();
initialDate = AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc)

%% Setup orbit propagator
%gravitation coefficient
mu =  3.986004415e+14

%Orbit construction as Keplerian
initialOrbit = KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu)

%Simple extrapolation with Keplerian motion
kepler = KeplerianPropagator(initialOrbit);

%Set the propagator to slave mode (could be omitted as it is the default mode)

%% Setup propagation time
%Overall duration in seconds for extrapolation
duration = 180*60.0

%Stop date
finalDate =  AbsoluteDate(initialDate, duration, utc)

%Step duration in seconds
stepT = 30.0

%% Perform propagation
%Extrapolation loop
cpt = 1;
extrapDate = initialDate
while extrapDate.compareTo(finalDate) <= 0
    currentState = kepler.propagate(extrapDate);
    fprintf('step %d: time %s %s\n', cpt, char(currentState.getDate()), char(currentState.getOrbit()))
    P(:,cpt)=[coord.getX coord.getY coord.getZ]';
    extrapDate = AbsoluteDate(extrapDate, stepT, utc);


Hi Petrus,

I don’t know why this example has not been migrated with the others. I temporarily disabled the redirection in Apache server to allow access to the wiki of our old forge. The example you are looking for is here:




Thanks a lot for this example.

I still have a problem to run this script, the command window return me :

Undefined variable “org” or class “”.
Error in PropagationDistribution (line 19)

Have got any idea to solve this issue ?


listed #5


Hi @Tintin

What version of Orekit do you use ? To my mind, your problem is that you don’t use a correct version of Java on your Matlab interface.

You shall use, at least, Java 8 to run correctly Orekit on your Matlab interface (if your version of Orekit is greater than 8.0).

To check your version of Java, on your Matlab terminal write : version -java

In the case of your Java version is lower than 8, download the correct jdk version and follow the recommendations on the Mathworks website depending if you are using Linux or Windows.

Best regards,