Documentation:Reference:Matlab - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search


Setting the Matlab Search Path

Once you have installed the MDSplus software on your desktop computer you can read and write data to and from MDSplus trees using Matlab. The m-file functions for MDSplus operations will be in your MDSplus directory, usually in C:\Program Files\MDSplus\Matlab for a standard Windows installation. You should add this folder to your Matlab search path using the Set Path... option from the File menu.

Possible Problems

Some users may have difficulty getting Matlab to find the necessary files. If you get an error message indicating that Matlab cannot find a necessary library file try copying the file MdsIpShr.dll from the C:\Program Files\MDSplus folder into the C:\Program Files\MDSplus\Matlab folder.

Example Usage

If there is an MDSplus server on your Local Area Network at address 123.456.7.89 and a tree on the server named mytree then you connect and read data like this:

 mdsconnect('123.456.7.89')
 mdsopen('mytree',42)
 somenumbers = mdsvalue('\data_node')
 mdsclose
 mdsdisconnect

In the above example we opened shot 42 of mytree and read data from the node with tag name data_node into a Matlab workspace variable named somenumbers. Most of the commands above will return some kind of answer when executed. Of importance is the fact that the mdsopen command will return the pulse number if successful and nothing if unsuccessful.

To write data simply use the mdsput command:

 mdsput('\data_node',somenumbers)

In the above example somenumbers can be any Matlab variable, including multi-dimensional arrays.

Decoding Error Messages

MDSplus can sometimes answer a request with a cryptic error message number. For example, if you try to store text in a numeric usage node you get the return code 265388426. Fortunately we can ask the MDSplus server to explain things with the mdsgetmsg command. Try this one:

 mdsgetmsg(265388426)