Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
interface .NET/ VC++ and Matlab

Subject: interface .NET/ VC++ and Matlab

From: Vihang Patil

Date: 16 Jan, 2008 11:14:02

Message: 1 of 8

Hello
I would like to interface .Net or VC++ with Matlab.
In brief, there is some code which is developed in .NET or
VC++ and now I want to execute that code in Matlab.
I have absolutely no programming knowledge and knowhow
whatsoever about .NET and VC++ and one of my friend will
be developing the code in either .NET or VC++ which I am
interested to execute in Matlab
Now, my questions are;
1. How do I do this?
2. Should I use the code from .NET/VC++ and modify somehow
to make it work in Matlab? or should I ask him to give me
a dll? or something else which can be called in Matlab?

Please help. If some one can provide any small example
would really be useful

Regards
Vihang


 

Subject: interface .NET/ VC++ and Matlab

From: Vihang Patil

Date: 18 Jan, 2008 09:25:04

Message: 2 of 8

any help?

Subject: interface .NET/ VC++ and Matlab

From: Kevin

Date: 19 Jan, 2008 00:03:02

Message: 3 of 8

On Jan 18, 10:25=A0am, "Vihang Patil" <vihang_pa...@yahoo.com> wrote:
> any help?

I'm also intressested in an answer, I have a simular question but also
still no answer :-s I hope someone has an answer??!!

Subject: interface .NET/ VC++ and Matlab

From: John reilly

Date: 22 Jan, 2008 13:43:02

Message: 4 of 8

The answer depends upon the code you want to call from
MATLAB.

If unmanaged (i.e. straight C/C++), the (probably) easiest
thing to do is to wrap it in an old-school Windows DLL.
You can use MATLAB loadlibrary/calllib to access it. don't
forget to export your DLL's entry points as extern "C". If
your interface is simple, this will be the easiest. If
your interface is more complicated, you may want to write a
C mex wrapper that you call from MATLAB, and that wrapper
links to your library, translating the MX-Array arguments
to/from C.

If your code is managed (i.e. runs on the CLR), much more
difficult. In that case, you'll need to create a C mex
wrapper that hosts the CLR for you. CodeProject.com will
help you out there.

hth.

reilly.



"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fmkotq$4tv$1@fred.mathworks.com>...
> Hello
> I would like to interface .Net or VC++ with Matlab.
> In brief, there is some code which is developed in .NET
or
> VC++ and now I want to execute that code in Matlab.
> I have absolutely no programming knowledge and knowhow
> whatsoever about .NET and VC++ and one of my friend will
> be developing the code in either .NET or VC++ which I am
> interested to execute in Matlab
> Now, my questions are;
> 1. How do I do this?
> 2. Should I use the code from .NET/VC++ and modify
somehow
> to make it work in Matlab? or should I ask him to give me
> a dll? or something else which can be called in Matlab?
>
> Please help. If some one can provide any small example
> would really be useful
>
> Regards
> Vihang
>
>
>

Subject: interface .NET/ VC++ and Matlab

From: Nishtha Nagrath

Date: 7 Mar, 2008 11:19:01

Message: 5 of 8

"John Reilly" <jrhokie1.nospam@yahoo.com> wrote in message
<fn4rt6$2cq$1@fred.mathworks.com>...
> The answer depends upon the code you want to call from
> MATLAB.
>
> If unmanaged (i.e. straight C/C++), the (probably) easiest
> thing to do is to wrap it in an old-school Windows DLL.
> You can use MATLAB loadlibrary/calllib to access it. don't
> forget to export your DLL's entry points as extern "C". If
> your interface is simple, this will be the easiest. If
> your interface is more complicated, you may want to write a
> C mex wrapper that you call from MATLAB, and that wrapper
> links to your library, translating the MX-Array arguments
> to/from C.
>
> If your code is managed (i.e. runs on the CLR), much more
> difficult. In that case, you'll need to create a C mex
> wrapper that hosts the CLR for you. CodeProject.com will
> help you out there.
>
> hth.
>
> reilly.
>
>
>
> "Vihang Patil" <vihang_patil@yahoo.com> wrote in message
> <fmkotq$4tv$1@fred.mathworks.com>...
> > Hello
> > I would like to interface .Net or VC++ with Matlab.
> > In brief, there is some code which is developed in .NET
> or
> > VC++ and now I want to execute that code in Matlab.
> > I have absolutely no programming knowledge and knowhow
> > whatsoever about .NET and VC++ and one of my friend will
> > be developing the code in either .NET or VC++ which I am
> > interested to execute in Matlab
> > Now, my questions are;
> > 1. How do I do this?
> > 2. Should I use the code from .NET/VC++ and modify
> somehow
> > to make it work in Matlab? or should I ask him to give me
> > a dll? or something else which can be called in Matlab?
> >
> > Please help. If some one can provide any small example
> > would really be useful
> >
> > Regards
> > Vihang
> >
> >
> >
>


Hi all
I am new to MATLAB.I want to write c++ wrappers in
MATLAB.For this i have made a project in VC++ and want to
use this.
What i want to know is that is it necesaary to write a
static library in VC++ to call it from MATLAB or any MFC
application can be used to do the same.
Kindly help.

Thanks in advance

Subject: interface .NET/ VC++ and Matlab

From: Benjamin

Date: 22 Mar, 2009 13:37:02

Message: 6 of 8

"John Reilly" <jrhokie1.nospam@yahoo.com> wrote in message <fn4rt6$2cq$1@fred.mathworks.com>...
> The answer depends upon the code you want to call from
> MATLAB.
>
> If unmanaged (i.e. straight C/C++), the (probably) easiest
> thing to do is to wrap it in an old-school Windows DLL.
> You can use MATLAB loadlibrary/calllib to access it. don't
> forget to export your DLL's entry points as extern "C". If
> your interface is simple, this will be the easiest. If
> your interface is more complicated, you may want to write a
> C mex wrapper that you call from MATLAB, and that wrapper
> links to your library, translating the MX-Array arguments
> to/from C.
>
> If your code is managed (i.e. runs on the CLR), much more
> difficult. In that case, you'll need to create a C mex
> wrapper that hosts the CLR for you. CodeProject.com will
> help you out there.
>
> hth.
>
> reilly.
>

Thanks for this message, another hint to understanding my problem.

I want to access from Matlab an API which uses .NET. Compiling my C++ function to a standalone program (.exe) works fine, but calling it from Matlab causes a segmentation fault with the message "Unknown Windows exception of
type=e0434f4d was not caught."

As you have written above, it seems that one has to write a wrapper function which links the unmanged code (Matlab) with the mananged code (.NET API). Since rarely using C++, I'm not in expert in such things. I would create two libraries. On contains the Matlab gateway function and is compiled without the /clr option (common language runtime support). The second contains the call of the API and is compiled with the /clr option. Is this right?

Best regards,
Benjamin

Subject: interface .NET/ VC++ and Matlab

From: Benjamin

Date: 25 Mar, 2009 16:56:01

Message: 7 of 8

I just found a solution. The new version of Matlab (2009a) comes with an interface to the .NET framework. Now it is ridiculously easy to use such a library. Just look in the Matlab help.

Halleluja!

Subject: interface .NET/ VC++ and Matlab

From: Thomas

Date: 7 Dec, 2009 10:35:20

Message: 8 of 8

"Benjamin" <benjamin.schubert_removethis_@hhi.fraunhofer.de> wrote in message <gqdnn1$11n$1@fred.mathworks.com> ...
> Ich habe eine L?sung gefunden. Die neue Version von Matlab (2009a) kommt mit einer Schnittstelle zu. NET Framework. Nun ist es l?cherlich einfach, eine solche Bibliothek zu verwenden. Schauen Sie in der MATLAB-Hilfe.
>
> Halleluja!
if you can do your solution here post, so that I can solve my problem

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us