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:
call matlab (dll) at dot net

Subject: call matlab (dll) at dot net

From: Buang Hong

Date: 23 Jul, 2007 07:53:38

Message: 1 of 9

Hi,
I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.

So, anyone here faced same problem and got any good solution?

Thank....

Subject: call matlab (dll) at dot net

From: Buang Hong

Date: 25 Jul, 2007 01:22:48

Message: 2 of 9

"Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> Hi,
> I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
>
> So, anyone here faced same problem and got any good solution?
>
> Thank....

Why no body help me?????

Subject: call matlab (dll) at dot net

From: John reilly

Date: 25 Jul, 2007 19:04:03

Message: 3 of 9

Hi Buang,

first off, no one had probably replied because no one who has read this post has an answer. you are not guaranteed a response just by posting. these folks here are all pretty good about helping. please, patience and gratitude...

.net builder converts your m-script into a COM object. that means that any call from managed code (e.g. C#) has the overhead of P/Invoke. second, creating the COM object is expensive in that it has to start the MCR, loading all the DLLs, and unpacking the ctf file.

so it is expected that creating the object and the first call will be slow. if your process, without exiting, and using the same object instance, repeats the call, you should see much faster response, no?

i haven't used .net builder, but i used C/C++ MCC and found that initialization was a dog, and then everything was very fast after that.

hth.

reilly.


"Buang Hong " <vbh83_com@yahoo.com> wrote in message <f868l8$rdq$1@fred.mathworks.com>...
> "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> > Hi,
> > I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
> >
> > So, anyone here faced same problem and got any good solution?
> >
> > Thank....
>
> Why no body help me?????
>

Subject: call matlab (dll) at dot net

From: Buang Hong

Date: 26 Jul, 2007 01:40:34

Message: 4 of 9

"John Reilly" <jrhokie1.nospam@yahoo.com> wrote in message <f886r3$9fa$1@fred.mathworks.com>...
> Hi Buang,
>
> first off, no one had probably replied because no one who has read this post has an answer. you are not guaranteed a response just by posting. these folks here are all pretty good about helping. please, patience and gratitude...
>
> .net builder converts your m-script into a COM object. that means that any call from managed code (e.g. C#) has the overhead of P/Invoke. second, creating the COM object is expensive in that it has to start the MCR, loading all the DLLs, and unpacking the ctf file.
>
> so it is expected that creating the object and the first call will be slow. if your process, without exiting, and using the same object instance, repeats the call, you should see much faster response, no?
>
> i haven't used .net builder, but i used C/C++ MCC and found that initialization was a dog, and then everything was very fast after that.
>
> hth.
>
> reilly.
>
>
> "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f868l8$rdq$1@fred.mathworks.com>...
> > "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> > > Hi,
> > > I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
> > >
> > > So, anyone here faced same problem and got any good solution?
> > >
> > > Thank....
> >
> > Why no body help me?????
> >
>

Sorry for "un-patience" and "un-gratitude".....

First time i call is slow, but i run the program second time without exiting, it look also very slow.

Thanks...

Subject: call matlab (dll) at dot net

From: Buang Hong

Date: 27 Jul, 2007 07:42:01

Message: 5 of 9

"Buang Hong " <vbh83_com@yahoo.com> wrote in message <f88u2i$b11$1@fred.mathworks.com>...
> "John Reilly" <jrhokie1.nospam@yahoo.com> wrote in message <f886r3$9fa$1@fred.mathworks.com>...
> > Hi Buang,
> >
> > first off, no one had probably replied because no one who has read this post has an answer. you are not guaranteed a response just by posting. these folks here are all pretty good about helping. please, patience and gratitude...
> >
> > .net builder converts your m-script into a COM object. that means that any call from managed code (e.g. C#) has the overhead of P/Invoke. second, creating the COM object is expensive in that it has to start the MCR, loading all the DLLs, and unpacking the ctf file.
> >
> > so it is expected that creating the object and the first call will be slow. if your process, without exiting, and using the same object instance, repeats the call, you should see much faster response, no?
> >
> > i haven't used .net builder, but i used C/C++ MCC and found that initialization was a dog, and then everything was very fast after that.
> >
> > hth.
> >
> > reilly.
> >
> >
> > "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f868l8$rdq$1@fred.mathworks.com>...
> > > "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> > > > Hi,
> > > > I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
> > > >
> > > > So, anyone here faced same problem and got any good solution?
> > > >
> > > > Thank....
> > >
> > > Why no body help me?????
> > >
> >
>
> Sorry for "un-patience" and "un-gratitude".....
>
> First time i call is slow, but i run the program second time without exiting, it look also very slow.
>
> Thanks...

Hi,
Because of unexpected error, it look already more faster during run the second time. But now i try to read image with "imread", for small image is ok (a bit slow), but when image's size is bigger (600 x 300), the program will hang. Anybody faced same problem and got any solution?

Thank...

Subject: call matlab (dll) at dot net

From: John reilly

Date: 27 Jul, 2007 12:00:17

Message: 6 of 9

Hi,

you know what is interesting? there is a post on this group from Wei Seng, and he is having the exact same issue! i don't have any idea why increasing the image size would hang your program. perhaps you could create a small program that replicates the problem and contact TMW?

reilly.


> Sorry for "un-patience" and "un-gratitude".....
> >
> > First time i call is slow, but i run the program second time without exiting, it look also very slow.
> >
> > Thanks...
>
> Hi,
> Because of unexpected error, it look already more faster during run the second time. But now i try to read image with "imread", for small image is ok (a bit slow), but when image's size is bigger (600 x 300), the program will hang. Anybody faced same problem and got any solution?
>
> Thank...

Subject: call matlab (dll) at dot net

From: Buang Hong

Date: 28 Jul, 2007 00:51:04

Message: 7 of 9

"John Reilly" <jrhokie1.nospam@yahoo.com> wrote in message <f8cmoh$5j$1@fred.mathworks.com>...
> Hi,
>
> you know what is interesting? there is a post on this group from Wei Seng, and he is having the exact same issue! i don't have any idea why increasing the image size would hang your program. perhaps you could create a small program that replicates the problem and contact TMW?
>
> reilly.
>
>
> > Sorry for "un-patience" and "un-gratitude".....
> > >
> > > First time i call is slow, but i run the program second time without exiting, it look also very slow.
> > >
> > > Thanks...
> >
> > Hi,
> > Because of unexpected error, it look already more faster during run the second time. But now i try to read image with "imread", for small image is ok (a bit slow), but when image's size is bigger (600 x 300), the program will hang. Anybody faced same problem and got any solution?
> >
> > Thank...
>

I know tat Wei Seng and me faced same problem, and we already hv communication. But we still dont know where is the problem.

Subject: call matlab (dll) at dot net

From: Iwan Kelaiah

Date: 20 Mar, 2013 10:17:07

Message: 8 of 9

"Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> Hi,
> I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
>
> So, anyone here faced same problem and got any good solution?
>
> Thank....

Hi Buang,

Have you solved this issue yet? I am facing similar problem. My dll is small but calling the function from C# VS2010 takes forever. After the first call, it is still slow.

Any suggestion would be greatly appreciated.

Regards,
Iwan

Subject: call matlab (dll) at dot net

From: ade77

Date: 20 Mar, 2013 12:02:05

Message: 9 of 9

"Iwan Kelaiah" <iwan.kelaiah@gmail.com> wrote in message <kic2b3$apj$1@newscl01ah.mathworks.com>...
> "Buang Hong " <vbh83_com@yahoo.com> wrote in message <f81mq2$1np$1@fred.mathworks.com>...
> > Hi,
> > I'm working on integrate the matlab with dot net (C#). I write a simple function at matlab, then compile it into dll using dot net builder. So, i using dot net window application to call the dll, it work. But the problem is very slow, i mean the return result from dll.
> >
> > So, anyone here faced same problem and got any good solution?
> >
> > Thank....
>
> Hi Buang,
>
> Have you solved this issue yet? I am facing similar problem. My dll is small but calling the function from C# VS2010 takes forever. After the first call, it is still slow.
>
> Any suggestion would be greatly appreciated.
>
> Regards,
> Iwan

The first question is why are you creating this DLL and using with C#, why can't you just do everything in MATLAB...

if speed is very important to you in your image processing, it makes sense to integrate your MATLAB with C++ or C, rather than C#.
of course every software has strenghts and weaknesses..
it will be wise to see your MATLAB code and confirm first that your MATLAB code in itself is not slow when handling large images.

The important thing is to know what your intention is in your final delivery and probably offer suggestion about what to do..

Regards
Ade

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