From: Ashish Uthama on 12 Apr 2010 10:07 On Mon, 12 Apr 2010 11:15:21 -0300, Josh <jstreufe(a)utk.edu> wrote: > Ashish, > > I'm new to Matlab and really just need to execute a function from the > .NET COM interface. > I'm in need of some simple guidance I thought the Mathworks example > could provide. > If I had a function (addtwo.m): > -function addtwo(x,y) > -%adds two numbers, vectors, etc > -% print the result of x + y > - x + y > -end > > How do I call that in the .NET COM, similar to the example Mathworks > provides? > For a MATLAb function function sum2 = addtwo(x,y) sum2=x+y end This ought to work (I havent tested it) %x and y are numerical objects myMATLAB.PutWorkspaceData("transIn","base", x); myMATLAB.PutWorkspaceData("transIn","base", y); myMATLAB.Execute("addtwo(x,y)"); myMATLAB.GetWorkspaceData("transOut", "base", out sum2);
From: Josh on 12 Apr 2010 11:57 Thanks Ashish. That helps, where on my server should the *.m file reside? -Josh
From: Ashish Uthama on 12 Apr 2010 12:06 On Mon, 12 Apr 2010 12:57:04 -0300, Josh <jstreufe(a)utk.edu> wrote: > Thanks Ashish. That helps, where on my server should the *.m file > reside? > > -Josh Josh, Anywhere, provided you 'addpath' to the directory.: Add this line in the constructor: myMATLAB.Execute("addpath <path to dir>"); (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/addpath.html)
From: Josh on 12 Apr 2010 13:31 Still getting the COMException message... -Josh
From: Ashish Uthama on 12 Apr 2010 13:02 On Mon, 12 Apr 2010 14:31:04 -0300, Josh <jstreufe(a)utk.edu> wrote: > Still getting the COMException message... > > -Josh Could you post your code? I am not too familiar with IIS/Web services, but someone else here might be able to help better. Also, maybe these examples would give you some more ideas: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f135590.html Or please paste this in the MATLAB command window: web([docroot,'/techdoc/matlab_external/f135590.html']) If you want a faster help, consider contact tech support: http://www.mathworks.com/support/contact_us/index.html
First
|
Prev
|
Pages: 1 2 Prev: Sparse matrices not as advertised! Next: Trouble with trigger and time-out |