473,322 Members | 1,562 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,322 software developers and data experts.

has anyone successfully called matlab functions in c#?

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
function ans=add(a,b)
ans=a+b;
code in c# as follows:
[WebMethod]
public int show()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.show(1,ref obj,4);
return (int)obj;

}
this returns 4;

but the following:
[WebMethod]
public int add()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.add(1,ref obj,4,5);
return (int)obj;

}
this breaks down.
could anyone please help me with it?
thanks!

P.S

while debugging i learn that this program breaks at line:
st.add(1,ref obj,4,5);
which means the function wrttin in matlab wasn't correctly called;

Mar 22 '07 #1
2 2727
The exception type and message would be helpful. Also, I'm assumming you
used the MATLAB Compiler to create a dll from your .m files. Provide more
information on how you have everything set up.

You might want to also consider MATLAB Builder for .NET. Go the the
Mathworks website and check it out. It's an extension of the MATLAB Compiler
that creates .NET assemblies out of MATLAB code.

"eric_jin" wrote:
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
function ans=add(a,b)
ans=a+b;
code in c# as follows:
[WebMethod]
public int show()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.show(1,ref obj,4);
return (int)obj;

}
this returns 4;

but the following:
[WebMethod]
public int add()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.add(1,ref obj,4,5);
return (int)obj;

}
this breaks down.
could anyone please help me with it?
thanks!

P.S

while debugging i learn that this program breaks at line:
st.add(1,ref obj,4,5);
which means the function wrttin in matlab wasn't correctly called;

Mar 22 '07 #2
bob

Hi eric,
As a test have you tried?
object obj = new object();
object a = new object();
object b=new object();
a=4;
b=5;
st.add(1,ref obj,4,5);
....

I see that st.show accepts the integer 'directly',
but its worth a test
regards
bob
On Thu, 22 Mar 2007 16:27:01 +0800, "eric_jin" <zi***@163.comwrote:
>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
function ans=add(a,b)
ans=a+b;
code in c# as follows:
[WebMethod]
public int show()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.show(1,ref obj,4);
return (int)obj;

}
this returns 4;

but the following:
[WebMethod]
public int add()
{
mat.matClass st=new mat.matClass();
object obj=new object();
st.add(1,ref obj,4,5);
return (int)obj;

}
this breaks down.
could anyone please help me with it?
thanks!

P.S

while debugging i learn that this program breaks at line:
st.add(1,ref obj,4,5);
which means the function wrttin in matlab wasn't correctly called;

Mar 23 '07 #3

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

Similar topics

6
by: Useko Netsumi | last post by:
windows xp with apache2? I follow all the instruction but I still got the following error when starting the apache2: The Apache service named reported the following error: >>> Cannot load...
0
by: shelly1500 | last post by:
hi al i want to convert some of matlab functions to c code.these functions are find, length, fft , end, min. can anyone help me
8
by: Allen | last post by:
Does anyone agree with me? If you have used Matlab, welcome to discuss it.
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; ...
1
by: holmescn | last post by:
I want to know who called these functions: the constructor the copy constructor the question from this code: class A { void func(); };
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...
2
by: sree12 | last post by:
Hi, Can anyone of u help me to call Matlab functions from c++ program. I need to write a c++ program and from this, i need to carry out a few calculations and need to plot the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.