E-CHAIM ionospheric model is available for C, IDL, and Matlab. We will describe the Matlab version only here.
This example is for E-CHAIM Matlab release 4.3.2. Free registration is required to download the E-CHAIM Zip archive. Extract this archive from Matlab:
unzip('Release_Matlab_CDB-4.3.2.zip')
cd('Release_Matlab_CDB-4.3.2/')The “ECHAIM.p” file is a function ECHAIM() accessed from Matlab. Unlike the “.m” script files one is used to, “.p” files are encrypted to keep source code private, but can be run just like “.m” files.
Let’s run a Matlab E-CHAIM self-test that will automatically compile the MEX code. The MEX compiled libraries will be under
Release_Matlab_CDB-4.3.2/nrlmsise/matlab_nrlmsise.mex*
Release_Matlab_CDB-4.3.2/aacgm/mex_aacgm.mex*
Where "mex*" is the file extension given by the Matlab command "mexext".
If you get an error message about compilers not being setup, there should be a link in the Matlab error on how to
setup the MEX compilers.
To share ".mex*" compiled libraries between computers - for example if your computer doesn't have C compilers compatible with Matlab available, the computers must both have the same operating system (e.g. macOS, Windows, Linux) and the same CPU architecture as seen by Matlab command computer('arch').
The Matlab release (e.g. R2026a) should also be the same, but sometimes MEX libraries compiled with an older Matlab version may
work
with a newer Matlab release--manually copy over the .mex* files to the appropriate directories on the other computer.
From Matlab:
ECHAIM(‘test’)If you get error
Unrecognized function or variable 'matlab_nrlmsise'
ECHAIM('create_nrlmsise')Then, generate an electron density altitude profile by running this example script "altitude_profile.m"
>> Y
Y =
struct with fields:
NmF2: 5.410904881893724e+11
hmF2: 2.447915856537269e+02
hmF1: 1.750454670458398e+02
HF1: 1.868798962096763
HBot: 39.312566734418397
HTop: 36.788016405991129
HE: 11.069314546679436
dens: [941×1 double]
NmE: 7.352674400770149e+09
NmF1: 7.021969909180861e+10
Lon: 69.500000000000000
Lat: 55
Alt: [60 61 62 63 64 65 66 67 68 69 70 71 … ] (1×941 double)
MLon: 1.430599130098475e+02
MLat: 52.020061248035766
MLT: 16.116123313057603
Dates: 23-Jan-2013 11:24:50
Err: [1×1 struct]
foEs: 3.013522515707382
hmEs: 1.026634910209048e+02
Es_Occurence: 0.119584693714115
dbDate: 10-Sep-2025 12:00:11
version: "4.3.2"
