473,413 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

calling matlab function in c#

suppose a simple matlab function
//add.m
function result=add(left,right)
result=left + right;

//end of add.m

use matlab comtool to encapsulate the function in fun.dll
and then use it in c#.net

i create a c# web service project to call
the matlab function add

but the function declaration has changed:
//create a instance;
fun.funClass st=new fun.funClass();

when i want to write st.add(parameters)

the declaration is
void add(int nargout,ref object,object,object)

which in matlab there're only two (left and right)

Could anyone please tell what's the meaning of int nargout and ref object?
And how to call the function add correctly?
Mar 20 '07 #1
2 5283
bob
Hi,
my guess is
nargout is number of output arguments
ref object will hold the result
the two 'val' objects are the input parameters
So I would be looking for C# code something like
object myResult;
int num1 =5;
int num2 =6;
st.add(1,myResult,num1,num2)
ie the following c# is similar in intent
private void button1_Click(object sender, EventArgs e)

{

int x = 5;

int y = 6;

object myResult;

myResult = new object();

Addem(ref myResult,x,y);

int z;

if( int.TryParse(myResult.ToString(),out z))

MessageBox.Show(" Result is " + z.ToString());

}

private void Addem(ref object myResult, int x, int y)

{

myResult = x + y;

}

HTH

bob
"zipls" <zi***@163.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
suppose a simple matlab function
//add.m
function result=add(left,right)
result=left + right;

//end of add.m

use matlab comtool to encapsulate the function in fun.dll
and then use it in c#.net

i create a c# web service project to call
the matlab function add

but the function declaration has changed:
//create a instance;
fun.funClass st=new fun.funClass();

when i want to write st.add(parameters)

the declaration is
void add(int nargout,ref object,object,object)

which in matlab there're only two (left and right)

Could anyone please tell what's the meaning of int nargout and ref object?
And how to call the function add correctly?


Mar 20 '07 #2
hi,bob!
the sol. is exactly what you've described
thanks a lot ^_^


"bob" <bo*@nowhere.comдÈëÏûÏ¢ÐÂÎÅ:Od**************@TK2M SFTNGP05.phx.gbl...
Hi,
my guess is
nargout is number of output arguments
ref object will hold the result
the two 'val' objects are the input parameters
So I would be looking for C# code something like
object myResult;
int num1 =5;
int num2 =6;
st.add(1,myResult,num1,num2)
ie the following c# is similar in intent
private void button1_Click(object sender, EventArgs e)

{

int x = 5;

int y = 6;

object myResult;

myResult = new object();

Addem(ref myResult,x,y);

int z;

if( int.TryParse(myResult.ToString(),out z))

MessageBox.Show(" Result is " + z.ToString());

}

private void Addem(ref object myResult, int x, int y)

{

myResult = x + y;

}

HTH

bob
"zipls" <zi***@163.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>suppose a simple matlab function
//add.m
function result=add(left,right)
result=left + right;

//end of add.m

use matlab comtool to encapsulate the function in fun.dll
and then use it in c#.net

i create a c# web service project to call
the matlab function add

but the function declaration has changed:
//create a instance;
fun.funClass st=new fun.funClass();

when i want to write st.add(parameters)

the declaration is
void add(int nargout,ref object,object,object)

which in matlab there're only two (left and right)

Could anyone please tell what's the meaning of int nargout and ref
object?
And how to call the function add correctly?




Mar 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul McGuire | last post by:
I've spent the past day or so working through the various complexities in calling Matlab routines from Python (please do not reply with suggestions to use Numpy/Scipy/etc. - our customer is using...
3
by: Mohammed Smadi | last post by:
Hi; Does anyone know if we can call matlab for a python or bash script while feeding the matlab script some command line arguments? I have an interactive matlab script which i want to automate...
9
by: Carl | last post by:
I am desperately looking for a way to call Python from Matlab. I have become used to Python's rich syntax and large number of libraries, and feel ridiculously clumsy being stuck with Matlab's...
3
by: Ajith Menon | last post by:
Do any body know how to use the functions available in the MATLAB using C#? ( To be specific, functions COHERE used to find Coherence and TFE to calculate Transfer function are needed. These...
1
by: eric_jin | last post by:
i wrote a c# webservice to call matlab functions. add is the function written in matlab,and then make it dll to use in c#; //add.m function result=add(left,right) result=left + right; ...
2
by: eric_jin | last post by:
i called function show() in a c# webservice //show.m function ans=show(x) ans=x; it works; but when i try to call add(),it breaks; //add.m
4
by: itcecsa | last post by:
Hi, I am implementing a small Python project, what I am going to do is to open Matlab and run some M-files, and get some output from Matlab command prompt. I have no idea how to open Matlab...
0
by: rperera | last post by:
1. I want to call a matlab function that my colleague did in Matlab from Python E.g >>matlab.DetermineOutputValues(text,ArrayOfValues) My input is text, and ArrayOfValues is the value...
1
by: sanctus | last post by:
I have a Matlab code which works fine in windows. Now I installed Xubuntu (because this way I have admin rights(=root) which I don't have on windows) and want to use the same code. To be able to...
14
by: Luna Moon | last post by:
Dear all, Can C++/STL/Boost do the vectorized calculation as those in Matlab? For example, in the following code, what I really want to do is to send in a vector of u's. All other...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.