LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass data to/from Matlab over ActiveX

Hi Ryan,

I'm not exactly sure why you are getting that error about mismatch. The "value" property is actually of type variant. LabVIEW casts this variant to the type specified by the control. Do you know anything about variant data types in Matlab? Since it supports ActiveX, I suspect that there is a variant data type. Just like others have posted, have you looked into using the Mathscript node in LabVIEW? There are some examples and tutorials on implementing this available through the NI Developer Zone and NI Example finder. I hope this helps!

Carla

National Instruments
Applications Engineer
0 Kudos
Message 11 of 14
(1,488 Views)

Carla,

Thanks for your response.

I worked more with my code yesterday and finally got the conversion to work. The mismatch error was comming from the fact that the array that I was passing, although it only had one column of data, was actually created as a 2D array. So when I tried to convert the variant to a 1D array in LabView, I got a mismatch error. Once I wired a 2D constant to the variant conversion, the error went away, and the array now transfers correctly.

Incidentally, do you know anything about the relative speeds of the activex methods versus the script nodes? I toyed with changing my code to use a script node when I couldn't get the conversion to work, but It looks like the script node is essentially performing the same process as the activex methods, but with the activex methods I have the benefit of being able to debug these types of conversion errors. I assume that if I attempted to specify the output of the script node as a 1D array when the array was in fact 2D, I would have run into the same problem, but with no feedback as to the cause of the error.

Thanks again,

Ryan

0 Kudos
Message 12 of 14
(1,479 Views)
It seems to me you didn't get much feedback working with the API calls either. The MATLAB script node also supports 1D arrays specifically. (I think on some level everything is actually a 2D array in MATLAB.)
0 Kudos
Message 13 of 14
(1,467 Views)

Hi Ryan,

I'm glad to hear your code is working now.  Although the MathScript and ActiveX approaches produce similar results, their implementations are different.  As explained in this KB, MathScript is "a high-level text-based programming language" within LabVIEW.  However, the MATLAB® Script Node does use ActiveX calls. 

I unfortunately do not have data to compare the performance of MathScript to ActiveX.  You may want to post on the LabVIEW MathScript forum for more information.  

Jennifer R.
National Instruments
Applications Engineer
0 Kudos
Message 14 of 14
(1,439 Views)