xarray
is an N-dimensional labeled array, inspired by xarray implemented in Python.
The purpose of this xarray
on MATLAB project is basically a port of the original (Python) xarray.
Currently, xarray
has a class of arrays called DataArray
. Here is an example of the 2x3 2-dimensional DataArray
da = xarray.DataArray([10.1 10.4 12.3; 20.3 20.5 24.2] ...
, dims = {'x', 'time'}...
, coords = {'x', [2.5, 4.4], 'time', [0 .1 .2]})
The most important feature of DataArray
is the ability to select array elements by axis name. From the data above, we slice out the array for
da.sel(x=4.4)
This selection method is revolutionary in two ways.
- You do not have to remember the dimension number of the axis (in this case,
x
is the first dimension of the data array). - No need to calculate the index on the axis that is desired value (in this case, the second element of the
x
axis).
The second point could be realized by writing matlab_array(:,x_vec==4.4)
and so on. However, not having to remember the dimension of the axis is useful when dealing with data that has many dimensions.
The element of DataArray can be accessed also by conventional MATLAB array style. This is an example which has same result as written above.
data(2,:)
See comparison_table.md for a table comparing how xarray
on MATLAB is written with the original xarray
notation.
Also, see readme.mlx for tutorial.
Just copy +xarray folder to your folder contained the code.