Jump to content

matlab dll in labview


Recommended Posts

Hi all,

I know this question was already ask more than one time. But my problem is: I want to use the a in matlab created dll. The m. file in matlab is a set of differential equations. I have already implemented this dll with a libary node, but actually nothing is happening. - And I think the problem is that there are no values are coming from the dll or can go into the dll.

If already found out that people advise to write a wrapper file. :headbang: Is it really necessary to created a wrapper file ? If yes, how do I create such a wrapper file? Or where can I find out how do this. Especially because I have no ideas about C/C++.

I really hope somebody can give some specific answers. :( It would be really important.

nice greetings,

keysk

Link to comment
  • 1 month later...
Hi all,

I know this question was already ask more than one time. But my problem is: I want to use the a in matlab created dll. The m. file in matlab is a set of differential equations. I have already implemented this dll with a libary node, but actually nothing is happening. - And I think the problem is that there are no values are coming from the dll or can go into the dll.

If already found out that people advise to write a wrapper file. :headbang: Is it really necessary to created a wrapper file ? If yes, how do I create such a wrapper file? Or where can I find out how do this. Especially because I have no ideas about C/C++.

I really hope somebody can give some specific answers. :( It would be really important.

nice greetings,

keysk

I'm not a Matlab expert, but AFAIK, the easiest way of using Matlab from LabVIEW is to build an ActiveX server to connect with the MCR (Matlab Runtime). That way the dll would be just for Matlab internal use (and because of that will only have the ActiveX method for registering and so) and instead of them you should use the methods the automation provides (i.e.: the methods you have created for that class).

Sorry if I have something wrong, I use Matlab-LabVIEW almost every day but only on the LabVIEW side :oops:.

Saludos,

Aitor

but

Link to comment
Hi Todd,

I have seen you questioned a thread which was concerning the problem using a Matlab m-file in a Labview VI. One of your suggestions was to use ActiveX, could you provide me with more information how to do this?? :blink:

thanks in advance,

Alex...

I hope you don't mind that I'm posting your PM, Alex.

When you open a vi that contains a Matlab script node, an instance of Matlab is automatically started that LabVIEW controls over ActiveX. You are only limited by the datatypes allowed into and out of the script node (plots work, too). Once the vi is closed (removed from memory/heirarchy) the Matlab instance closes.

I have found it most useful to run Matlab in batch mode using SysExec.vi. That way I can programatically create data files and m files.

--Todd

Link to comment
Thanks Aitor for your reply.

As I am a bit of a beginner, can you give me more information about how to build a ActiveX server to connect with the MCR???? And can I then use Labview without Matlab. ;)

As Todd says, you can use the Matlab script node (but be careful with the running threads, as it tends to take control of the UIThread). The script node uses Matlab, so you must have Matlab installed in every PC you want to run your application.

BUT if you build your application like a Matlab ActiveX server, you just need the MCR in the machine, not Matlab, and it's distributable. It's still a bit heavy, about 100Mb if I remember correctly.

You'll need to compile your matlab class with the Matlab's COM Builder (as I said, I'm no Matlab expert, so everybody feel free to correct me.). This shoud create an .exe file. Execute it, it creates a dll and registers it. Go to LabVIEW and create an ActiveX object, now you should see your new class in the list of available ActiveX servers. Select the creatable object you need, instantiate it and use it through the properties and methods (all of these is in the ActiveX palette in LV).

Saludos,

Aitor

Link to comment
I hope you don't mind that I'm posting your PM, Alex.

When you open a vi that contains a Matlab script node, an instance of Matlab is automatically started that LabVIEW controls over ActiveX. You are only limited by the datatypes allowed into and out of the script node (plots work, too). Once the vi is closed (removed from memory/heirarchy) the Matlab instance closes.

I have found it most useful to run Matlab in batch mode using SysExec.vi. That way I can programatically create data files and m files.

--Todd

I tried to use the matlab srcipt node in the beginning because I thought it would be the easiest way - but it did not work really (or let say it seemed, that it worked, if it wanted work) - :( -

Sorry if this is a complete stupid question: But what this it mean to run Matlab in batch mode and what is SysExec.vi????

kind regards,

Alex

Link to comment
You'll need to compile your matlab class with the Matlab's COM Builder (as I said, I'm no Matlab expert, so everybody feel free to correct me.). This shoud create an .exe file. Execute it, it creates a dll and registers it.

Aitor, given Alex's next question, this may be jumping in a bit deep. It took a while for (even) me to get Matlab's build system understood. It wasn't well documented.
Sorry if this is a complete stupid question: But what this it mean to run Matlab in batch mode and what is SysExec.vi????
Read the LabVIEW help for SysExec.vi (search for it) and the Matlab help for 'batch mode'. From the terminal (command line) you can type:
matlab -r asdf.m

to start Matlab and have it run asdf.m. If the last command is 'exit', Matlab closes. SysExec.vi lets you do this from LabVIEW. I sometimes use LabVIEW to generate data files that get used in the m-file - which then creates an output file.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.