DADiSP / MATLINK

MATLAB Code Execution Module

Mat linkMATLINK provides a simple interface for executing MATLAB (1) code directly from DADiSP. Any MATLAB function or script can be processed just as if it were a native DADiSP function.

No need to rewrite code or manipulate temporary data files. MATLINK combines the functionality of existing MATLAB programs with the ease and power of the DADiSP Worksheet environment.

Series, arrays, scalars and strings are exchanged seamlessly. Series and array results returned from MATLAB plot automatically in DADiSP. MATLAB code embedded into a Worksheet Window formula is hot linked and automatically re-executes when the Window updates.

Key features

  • Seamless execution of MATLAB dode from DADiSP.
  • Runs built-in and custom MATLAB functions or scripts.
  • Avoid code rewrites, use any MATLAB program as is.
  • Supports expression evaluation in normal MATLAB syntax.
  • Freely mix DADiSP functions and MATLAB code.
  • Automatic visualisation of series and array results.
  • Bi-directional exchange of program variables.
  • Handles both real and complex data.
  • Supports scalar and string data types.
  • Supports MATLAB Version 4.0 and higher.

(1) MATLAB is a registered trademark of The MathWorks, Inc.

MATLAB code execution module

MATLINK runs MATLAB programs directly from DADiSP and exchanges data between DADiSP and MATLAB. Both built-in and custom MATLAB functions or scripts are executed just as if they were native DADiSP functions. Arrays, scalar and string data are exchanged transparently in fast binary format using the ActiveX Automation interfaces of DADiSP and MATLAB.

How does it work?

The key to the simplicity and power of MATLINK resides in the MATLAB Object created by DADiSP. The MATLAB Object supports the execution of any MATLAB expression from the MATLAB environment and returns the results to DADiSP via ActiveX. Because the code is still run in MATLAB the results are exactly the same as would normally be produced by MATLAB.

ML Dot Syntax

The default name of the MATLAB Object is ml. Simply preface the original MATLAB function name with ml. to run any MATLAB code from DADiSP. For example, the following DADiSP command displays the current version of the available MATLAB release:

ml.version

The returned version text is displayed by DADiSP. Because the connection to MATLAB is automatically established when the MATLAB Object is first invoked, explicit initialisation is not required.

Mix and match

DADiSP and MATLAB functions can be combined and used interchangeably within a Worksheet or SPL functions. For example:

W1: gnorm(10000, 1)
W2: ml.diff(W1)

W1 contains 1000 samples of Gaussian distributed random noise. The data is then processed by the MATLAB diff function and displayed in W2. When W1 changes, W2 automatically updates and the new data is processed by MATLAB.

The MATLAB diff function executes just like any other DADiSP function except:

1. DADiSP sends the required data to MATLAB

2. MATLAB executes the function

3. The results are returned to DADiSP.

The entire process is perfomed automatically, transparently and efficiently.

DADiSP and MATLAB functions can be freely mixed. For example:

W1: gnorm(10000, 1)
W2: movavg(ml.diff(w1), 10)

The MATLAB diff function is applied to the data in W1 and the result is smoothed by means of a 10 point moving average computed by the DADiSP movavg function. Any combination of DADiSP and MATLAB functions can be combined in this manner.

Data exchange

Although generally not required, MATLINK supports explicit data exchange between DADiSP and MATLAB variables. For example:

 // assign a DADiSP series to a MATLAB variable
ml.MatVar = 1..100;
// return a MATLAB variable to DADiSP and process
x = 10 * ml.MatVar;

The MATLAB variable MatVar is created and assigned a series of values from 1 to 100. The DADiSP variable x contains the value of the MATLAB variable multiplied by 10. Though required data transfers are automatically handled by the MATLAB Object, the “dot syntax” provides a natural method for exchanging program variables when desired.

MATLAB command prompt

MATLAB expressions in original MATLAB syntax are evaluated directly by using the > prompt.

W1: >1:100
W2: integ(W1)

W1 contains the values 1 through 100 as produced by the MATLAB expression 1:100. W2 integrates the data. Again, a change to W1 automatically updates W2.

Although the equivalent data in W1 can be generated natively by DADiSP with the statement 1..100, the expression 1:100 is standard MATLAB syntax. Any expression in standard MATLAB syntax is supported and evaluated when the expression is prefaced by the > prompt.

Additional features

The mlhelp function displays the original help text for MATLAB functions. For example:

mlhelp eig

The standard help information for the MATLAB eig function is displayed in DADiSP.

The mldoc function displays the online documentation for MATLAB functions. For example:

mldoc fft

The online documentation for the MATLAB fft function is displayed in DADiSP.

Multiple return values from MATLAB functions is supported.

W1: rand(10)
W2: (v, d) = ml.eig(W1);d

The MATLAB eig function returns two arrays. The second array, a diagonal matrix of eigenvalues, is placed and dislayed in W2.

Error messages or warnings produced by MATLAB are displayed in DADiSP. Functions that produce textual results are presented in a pop-up dialogue box. For example, to display a list of currently available MATLAB variables with corresponding data types:

ml.whos

Requirements

MATLINK requires a licensed copy of MATLAB Version 4.0 or higher to be available from the machine running DADiSP.

DADiSP 6.5 B01 or higher is also required. Contact us for information about updating your current version of DADiSP.

MATLINK functions

 

MATLINK Functions
mldoc Display MATLAB online help.
mleval Evaluate a MATLAB function with optional arguments.
mlexec Execute an expression in MATLAB syntax.
mlget Get data from a MATLAB variable.
mlhelp Display help text on a MATLAB function.
mlinit Initialses the connection with MATLAB and creates a MATLAB Object.
mlput Put data to a MATLAB variable.
mlshow Shows or hides the current MATLAB Automation server.

 

Hier geht es weiter

Sie möchten kaufen?

Was sagen unsere Kunden über uns?

Tutor was very knowledgeable and taught in a way that was easy to follow

KH, Uxbridge, UK

Your web page is simply brilliant. Congratulations!

CF, Kirknewton, UK

Hi Bob, Thank you so much for this and your prompt reply. It is such a relief, I can’t tell you! I will try downloading it now. I can’t thank you enough for your kindness as well as efficiency.

C

Bob’s great, he should be franchised.