09-28-2017 03:18 PM
I'm trying to run MATLAB code once a user presses a button in my DIAdem GUI. I followed the instructions listed on the page here: <http://digital.ni.com/public.nsf/allkb/1706BA4C65A8533686256C630062DD03>
However, I couldn't find the required filepath in a National Instruments folder to detach the ScriptLibrary.ocx. (nor does the file itself seem to exist). After installing the matlab plugin and disregarding the other instructions, I built my code to look something like
Sub DialogBox_EventInitialize Dim oMatLabM Set oMatLabM = CreateObject("DIAdem.ScriptLibrary.MATLAB") End Sub Sub ButtonRun_EventClick Call oMatLabM.Execute("load filepath\filename.mat") 'etc End Sub
This gives me an error listed from the first block of code as:
ActiveX component can't create object: 'DIAdem.ScriptLibrary.MATLAB'
Which I assume is related to not having detached the scriptlibrary.ocx. Any help getting DIAdem to run MATLAB would be much appreciated.
09-29-2017 09:29 AM
Hi d_gum,
That knowledgebase article you refer to says that it's for DIAdem 9.1, so that's about 10 years old at this point. I'm not familiar with that *.ocx it advocates and don't know how to find it or if it will still work with modern MatLab versions. What should still work is ActiveX, which is how the shipping DIAdem example "Communicating with MATLAB" suggests you should control an installed MatLab version from a running VBScript, like this:
If ( 10 > CLng(ProgramVersion) ) Then MsgBox("This example requires DIAdem 10.0 or higher") else On Error Resume Next Set oMatLabM = CreateObject("Matlab.Application") If Err.Number = 0 Then Call ML_DoDataStuff(oMatLabM) ' MATLAB will shutdown with the next statement Set oMatLabM = Nothing Else MsgBox "Matlab is not installed. DIAdem has stopped the script." End If end if
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-04-2017 10:42 AM
Thanks for pointing me in the right direction. I have some computers with Octave instead of MATLAB installed and was wondering if I had to modify anything in the script to get DIAdem to call the Octave ".m/.mat" files from the GUI. Tried running the script on computers with Octave and got the "MATLAB is not installed" error message, as expected.
Any help is much appreciated.
10-05-2017 12:01 PM
Hi d_gum,
If you are trying to connect to Octave rather than MATLAB®, then the key will be opening up an ActiveX connection to the Octave application rather than to MATLAB.Application. From there, the ActiveX automation API exposed is something that Octave will need to provide, so it may require some experimentation to find out the right commands necessary to run your scripts. I'd recommend searching online for resources on automating Octave via ActiveX.
Best regards,
Yiran Li
MATLAB® and Simulink® are registered trademarks of The Mathworks, Inc.