From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Matlab/Octave from DIAdem GUI

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.

0 Kudos
Message 1 of 4
(2,757 Views)

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

0 Kudos
Message 2 of 4
(2,731 Views)

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.

0 Kudos
Message 3 of 4
(2,705 Views)

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. 

0 Kudos
Message 4 of 4
(2,686 Views)