Click here to Skip to main content
12,996,975 members (134,612 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I Need some help with the calling of a matlab compiled DLL (C# under
deploytool). The matlab function is a simple function THAT takes two double and return a

i add necessary references to my c# project ...

and its my code :

Sum.Class1 a = new Sum.Class1();
           MathWorks.MATLAB.NET.Arrays.MWArray[,] s=new MWArray[1,3];
           a.sumab(2, 5, s);
             listBox1 .Items.Add(s);

the method (sumab) return void and i dont know how can get my output ...
im very amazing

if i just write a.sumab(2,5);
it gives me an error:

... MWMCR::EvaluateFunction error ...
Error using ==> sumab
Too many output arguments..


please help me friends
tnx a lot
Posted 28-Aug-12 1:31am
Updated 28-Aug-12 3:32am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It seems the function in the DLL is at least called. But of course if the function expects 3 Parameters the call
will produce an error. Usually in matlab if you want a return value from a function you call it
s = a.sumab(2, 5); 
since matlab doesnt have reference parameters.

I think you should rewrite your Matlab function so that it only excepts 2 parameters and of course returns the result sum.

See for example:[^]

But then again why even use Matlab for such a simple task...
sahrarainmelody 29-Aug-12 1:13am
i have a great program in matlab and i shoud convert it to dll for using in c# .... this is a simple instance for doing that .
my function in MATLAB is :

function c=sumab(a,b)

and i call it like this :

>> sumab(2,3)

ans =

so i dont know where is wrong .

can help me?

Legor 30-Aug-12 2:53am
Have you tried calling it in C# as i've mentioned?
s = a.sumab(2, 5);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100