DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab ActiveX control with DIAdem

I have successfully used DIAdem to transfer data back and forth with Matlab using Active, as well as run Matlab scripts. However, I would like to be able to see the Matlab command window (errors, warnings, etc.) as the script is running. Also, I have found that when having DIAdem open a Matlab .m file (using the NI files from the support website), variables that are 1 x 1 in size are not retrieved by DIAdem and in addition, some variables get a _1 etc. tagged onto the end of them. Any help would be great. Thanks.
0 Kudos
Message 1 of 5
(4,443 Views)
Hello Justin,

if you use the little ActiveX control we provided, the MATLAB command window is visible once you connect to MATLAB. If you run a script nothing happens in this window because echo is "off" by default.
Use the "Execute" method to send "echo on all" before you execute the M-script

The GetChannel method is optimized to transfer array from MATLAB to DIAdem and doesn't accept single variables. There is a work around you can use to retrieve single variables from MATLAB :
You can use "GetCharVar" which is a method of the ActiveX control to retrieve a (single) character variable. If your variable is of a different type, please use the MATLAB function num2str to convert it before you retrieve it.
Here is an example :
---------------------------
------------------
' load a file..
Call oMatLabM.Execute("load D:\Source\scriptlibrary\Test\ML_SingleRow.mat")
' convert variable A to string :
Call oMatLabM.Execute("zzz = num2str(A)")
' retrieve it :
myVar = oMatLabM.GetCharVar("zzz")
' show it
MsgBox(myvar)
---------------------------------------------
You may find it helpful to list all variables together with type and dimension. Please refer to the little script I have attached which shows how to list all variables in the current MATLAB workspace

Let me know if you need more details...
0 Kudos
Message 2 of 5
(4,443 Views)
hello:
how can I find the ActiveX for data transfering between matlab and diadem? I'm also finding it.
thank you
0 Kudos
Message 3 of 5
(4,443 Views)
http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/1706ba4c65a8533686256c630062dd03?OpenDocument
0 Kudos
Message 4 of 5
(4,443 Views)
Dear AndreasH,

I wish to transfer a channel w/ string values (actually, its the filename of the data I am opening) in DIAdem to Matlab using the mechanism you just mentioned.

I have tried it but it wont work. It gives me a double array in Matlab.Do you know how to get around this?

One last thing, do you know how to display the string in the channel in DIAdem like the way you do it in MAtlab.

Thanks in advance!

-Ham
0 Kudos
Message 5 of 5
(4,443 Views)