DHI MATLAB Toolbox
The DHI MATLAB Toolbox provides a number of tools and examples for working with DHI related data files within MATLAB.
The current version of the toolbox supports reading of all dfs file types, dfs0+1+2+3+u. It also supports reading network results, such as results from MIKE 1D, MIKE 11 or MIKE URBAN/MOUSE/MIKE+ (files with extensions .res11, .res1d, .prf, .xrf, .trf, .crf).
Content of this page
- How to get help
- Why a MATLAB Toolbox
- Download and installation
- Building a new releases of DHI MATLAB Toolbox
- Release notes
How to get help
This pages includes an introduction on how to get started, and a few things to be aware of.
Why a MATLAB TOOLBOX?
MATLAB provides a compact high-level technical programming/scripting language, and together with the DHI MATLAB Toolbox, it allows swift handling of time series data, analysis, visualisation and presentation. The MATLAB environment is very much hands-on and can be used without special programming skills for custom analysis of results from numerical models.
Download and installation
Check out the Requirements section below.
Download the DHI MATLAB Toolbox: DHI MATLAB Toolbox Releases download.
Get the DHIMatlabToolbox_XXXX.zip, where XXXX represents the version number. Unzip its content.
Assuming you unzip to the folder
C:\Matlab, then a folder called
should be created, including a lot files and a couple of subfolders.
Note that the C:\Matlab folder can be replaced with any other folder, according to user preferences; just replace it in the following.
C:\Matlab\mbin folder and subfolders should be added to the MATLAB search path. Start MATLAB, in the MATLAB command window, issue the command:
This will add recursively the folder to the MATLAB path for this MATLAB session only.
To add the folder permanently to the path, instead add the command to your startup.m file,
or use the menu ‘file’ - ‘Set Path’ and add the needed folders there.
Two folders are required to be in the MATLAB serach path, the
\mbin and the
You should now be ready to use the DHI MATLAB Toolbox.
The DHI MATLAB toolbox works on Windows only.
MATLAB must be installed.
Only the 64 bit version of MATLAB will work with the latest version of the DHI MATLAB Toolbox. Prior to Mike Release 2017, also a 32 bit version is available.
The current version of the toolbox has been tested on MATLAB R2018b, but earlier versions may also work. To read and write DFS files, MATLAB must be able to interact with .NET objects, which was introduced in MATLAB R2012b.
The current version of the DHI MATLAB toolbox does not require any MIKE Software to be installed. The toolbox contains all software required to work with DFS files.
Microsoft Visual C++ redistributables
The MIKE software native components (DFS, EUM, Projections and others) require the “Microsoft Visual C++ redistributable” for Visual Studio 2017 or later in order to run.
These redistributables are often already installed. They are installed automatically when installing MIKE Zero, MIKE+, MIKE Urban or MIKE SDK. In case they are not already installed, they can be downloaded and installed from:
Building a new releases of DHI MATLAB Toolbox
The DHI MATLAB Toolbox utilizes the MIKE Core NuGet packages. To build a new version of the toolbox run first:
- Download the
nuget.exefrom https://www.nuget.org/downloads, store it in
c:\Programs\nuget.exe, or update the
InstallPackages.batto match the location of the
- Run the
InstallPackages.bat: It will download the required NuGet packages to a
- Run the
BuildBin.bat: It will copy required content from the
packagesfolder to the
- Make a new MatlabDfsUtil.dll
- Go to the MatlabDfsUtil folder
- Run the MatlabDfsUtilBuild.bat. That will create a new MatlabDfsUtil.dll
- Copy the MatlabDfsUtil.dll to the mbin folder.
- Run the
- That puts all required files in the new DHIMatlabToolbox.zip.
- Give it a name matching the version and data of creation, i.e. something like DHIMatlabToolbox_v19.0.0-20201217.zip
New in Version 19 (2021)
1: The toolbox now contains all software as part of the toolbox. It is no longer required to install any MIKE Software for the toolbox to work. Check section on Requirements for details.
2: The use of
DHI.MIKE.Install to locate a MIKE installation is no longer required, and should be removed.
3: To locate the required assemblies, the most convenient is to use the method:
Note that now the file extension
'.dll' is also included,
which was not the case in previous versions of the toolbox.
The following lines are the most common lines required in order to work with dfs files
NETaddAssembly('DHI.Generic.MikeZero.DFS.dll'); NETaddAssembly('DHI.Generic.MikeZero.EUM.dll'); import DHI.Generic.MikeZero.DFS.*; import DHI.Generic.MikeZero.*.*;
4: The dfsTSO class has been removed from version 19 (2021) of the DHI MATLAB toolbox, since the underlying TSObject is no longer a part of the MIKE software suite. To continue using the dfsTSO class and its functionality, download instead the version 18 (Release 2020) or earlier of the toolbox. Check out the user guide in that release zip file for details of using and installing the toolbox.