MATLAB Interface

From OpenMBD
< HANtune
Revision as of 18:55, 21 October 2019 by Michiel (talk | contribs) (Set your model)
Jump to: navigation, search

HANtune can be interfaced with MATLAB® (and by extension Simulink®). We can do this by using the MATLAB engine and calling it from a script.

Note: You will need to have installed a version of MATLAB® with the Java MATLAB engine.

Connecting to the MATLAB Engine

Reading data from a running Simulink model

Set your model

#Change these to the name and location of your model
modelName = 'MyModel'
modelPath = 'C:\Users\Michiel Klifman\Desktop'

Adding folders to the MATLAB Search path

#Add folders to MATLAB path
from java.lang import System
scriptPath = System.getProperty("user.dir") + "\scripts\examples\MATLAB_Interface"
engine.eval("addpath('" + scriptPath + "')")
engine.eval("addpath('" + modelPath + "')")

Creating a daq list

Reading data from a running Simulink model