Click here to Skip to main content
Sign Up to vote bad
good
See more: C#HomeworkMatlab
hi
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
third...
 
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:31
Edited 28 Aug '12 - 3:32


1 solution

It seems the function in the DLL is at least called. But of course if the function expects 3 Parameters the call
a.sumab(2,5);
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:
http://thinkmetric.com/tuts/matlab/functions.html[^]
 
But then again why even use Matlab for such a simple task...
  Permalink  
Comments
sahrarainmelody - 29 Aug '12 - 1:13
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) c=a+b; and i call it like this : >> sumab(2,3) ans = 5 so i dont know where is wrong . can help me? tnx
Legor - 30 Aug '12 - 2:53
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 216
1 Sergey Alexandrovich Kryukov 169
2 Tadit Dash 154
3 Richard MacCutchan 145
4 Santhosh G_ 115
0 Sergey Alexandrovich Kryukov 10,338
1 OriginalGriff 7,965
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


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