Add your own alternative version
Stats
396.2K views 23.1K downloads 120 bookmarked
Posted
18 Nov 2003

Comments and Discussions



hi
I have this problem that matlab is not known to my C#. so I can't call it in my program. what should I do?
thank you





Hi Emanuele,
Your article is great.
I am trying to do the following:
I developed an interface with WPF.
However, it requires data to work.
That data is generated with a Simulink model and its corresponding simulation.
My attempt is to access the data generated in realtime to use it with the interface.
When I added the EngMATLib DLL to my project and ran your sample code to test it, I get the following error:
'Unable to load DLL 'libeng.dll': The specified module could not be found.'
Any clues?

Abdullah Garcia





Hi,
This was very good article, I tried to run the image demo and while I am running the code it stopped in this line:
MATInvoke.mxSetName(mta, name);
with the error: EntryPointNotFoundException in libmx.dll
can someone help on this error?
Thanks
Sg





Hello,
So I am interested in integrating calls to signal processing toolbox, i.e. butter, for filter design.
Let's use butter, for example.
Let's take the butter(n,Wn,'ftype') version. This can return [z,p,k] (zeros, poles, scalar), or [b, a] filter coefficients.
Actually... Writing this I think I found my own answer. There is a parameter in the Feval, nargout, which has the number of output arguments. I believe I use that: 3 for [z,p,k] and 2 for [b,a], and "magically" Matlab COM server knows the difference?
Thank you.
Best regards.





As subject states, good article. I've been searching for how to serialize data to MATLAB over COM. It should be more obvious in the documentation how to do this, or I haven't found the link yet. But now that I think about it, after having dealt in MATLAB code directly a bit, and having seen one or two simpler calls through COM, it's more obvious, MATLAB always likes to deal in twodimensional double arrays where numeric arrays are concerned. Once you get past the object array packaging of the response itself, that's plain to see. Thanks!





i have done some coding in vb10 for ECG and i want that ECG database in matlab.
ho wto do it ?





HI, It was realy helpful for me. thank you





Hi!
PROBLEM 1:
I have a problem with the last example you give using DllImport. For some reason I can't figure out how to use basic numeric types such as double, int32 etc.
My MATLABfile (*.m) is as follows:
function y = test(x)
z = cast(x, 'int32');
y = z+z;
end
After creating the DLL and imported the required mlftest()function I created a function that calls it:
public static Int32 mlfTestCsharp(Int32 x)
{
Int32 res = mlfTest(x);
return res;
}
When I call it in main() like this:
static void Main(string[] args)
{
Int32 x = 2;
Console.WriteLine("Matlab testlib: " + mlfTestCsharp(x));
}
I get an AccessViolationException telling me that I tried to access protected memory for reading or writing (the same message @kumar dhruva got). Can you please provide some feedback on this matter if it's not a problem for you?
PROBLEM 2:
In your last section "Examples and Usage" you use type Matrix. My question is  where is this Matrixtype defined?
Thank you very much for your time in advance!
RBA





Thanks





This is a very useful library...is there a way to use it with Octave?
Thanks...





Thank you very much for this article, it is very informative.
There is just one thing.. you say that .m files can be translated into DLLs and I think this is only possible if you have the MATLAB Compiler installed.. If that is so, you might want to mention it in the appropriate paragraph above. If not, please describe how to do it..
Thanks again for the code and this great article!
modified 15Jun12 14:35pm.






I am using MATLAB 7.12.0 (R2011a). Downloaded the demo code binary and tried it. Nothing worked. Guess this library doesn't work with my version of MATLAB.





Although you did not describe your problem.. which does help .. I assume you ran into the same thing I had..
I got a PInvokeStackImbalance exception when a function was called. Explicitly stating the calling convention solves this problem.
For example:
[DllImport("libeng.dll")]
public static extern IntPtr engOpen(string startcmd);
has to become:
[DllImport("libeng.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr engOpen(string startcmd);
Best wishes!





Hello all! I have problem:
I have a function createnet on matlab as:
function net =createnet()
a = magic(81);
input = a(1:81, 1:10);
b = magic(10);
target = b(1, 1:10);
network = newff(input, target, 20);
net = network;
return;
and then I build it to dotnet library and use it in csharp code but it have exception about "set adaptFcn" in subsasgn.m file in .//..//temp//../@network//subsasgn.m
Can eveybody help me! thanks all!!
This is exception message:
"System.Exception was unhandled
Message=
... MWMCR::EvaluateFunction error ...
Output argument "err" (and maybe others) not assigned during call to "C:\Users\hotoan\AppData\Local\Temp\hotoan\mcrCache7.9\CoreMT5\toolbox\nnet\nnet\@network\subsasgn.m>setAdaptFcn".Error in =>CreateMTANN.m at 34.
... Matlab Mcode Stack Trace ...
at
file C:\Users\hotoan\AppData\Local\Temp\hotoan\mcrCache7.9\CoreMT5\toolbox\nnet\nnet\@network\subsasgn.m,name subsasgn,line at 435.
at
file C:\Users\hotoan\AppData\Local\Temp\hotoan\mcrCache7.9\CoreMT5\toolbox\nnet\nnet\nnnetwork\newff.m,name new_5p1,line at 171.
at
file C:\Users\hotoan\AppData\Local\Temp\hotoan\mcrCache7.9\CoreMT5\toolbox\nnet\nnet\nnnetwork\newff.m,name newff,line at 89.
at
file C:\Users\hotoan\AppData\Local\Temp\hotoan\mcrCache7.9\CoreMT5\CodeMTANN\CreateMTANN.m,name CreateMTANN,line at 34.
Source=MWArray
StackTrace:
at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, Int32 numArgsIn, MWArray[] argsIn)
at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, MWArray[] argsIn)
at CoreMTANN.CoreMTANN.CreateMTANN(MWArray input, MWArray target, MWArray numHiddenNeural, MWArray goal, MWArray epochs, MWArray trainingRate)
at Presentation.fMain.CreateMTANN() in C:\Users\hotoan\Documents\Visual Studio 2010\Projects\MTANN\Presentation\fMain.cs:line 130
at Presentation.fMain.btnCreateMTANN_Click(Object sender, EventArgs e) in C:\Users\hotoan\Documents\Visual Studio 2010\Projects\MTANN\Presentation\fMain.cs:line 238
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Presentation.Program.Main() in C:\Users\hotoan\Documents\Visual Studio 2010\Projects\MTANN\Presentation\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
"





I just used your code... it's works fine! Tnx






Hi,
I am new to this forum,
and new to c# & MATLAB,
I am trying to run a c# program which is calling a matlab dll.
I am creating a mxMatrix from my local array and passing it to matlab, while I am trying to access the mxMatrix which is returned by matlab dll, i am getting the error "access violation, Attempted to read or write protected memory. This is often an indication that other memory is corrupt".
can someone suggest some solution.
Thanks
Dhruva





hello
I need to provide facility for Matlab to do bulk insert to SQL. Matlab provides ways to load .NET assembly and call .NET methods:
Assembly reference: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/net.addassembly.html
Method calls: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/brpb58s1.html#brpca5n1
However, we can't pass "Cell Array":
Example:
% 2 Dimensional array of numbers
a=[1 2 3; 3 4 5; 6 7 8]
aa=[1.1 2.2 3.3; 4.4 5.5 6.6; 7.7 8.8 9.9]
% Single dimension string array (2D not permitted)
b={'aaa0'; 'bbb0'; 'ccc0'}
bb={'aaa0','aaa1'; 'bbb0', 'bbb1'; 'ccc0', 'ccc1'}
c={'20100701' 1.11 2.22; '20100702' 3.33 4.44; '20100703' 5.55 6.66;}
"c" above is cellarray
Now, my only option is to wrap bulk insert logic in ATL COM server, and call from Matlab as such:
dbServer = actxserver('MyDBComServer');
The first article below shows how to build a simple ATL server in C++ but:
PROBLEM 1: sample shows only passing simple type such as string/BSTR  I need to pass a Matlab CellArray across (For this problem... I don't have much clue how CellArray is represented in memory as thereby passed across Matlab/COM/.NET borders)
PROBLEM 2: I don't have access to .NET System.Data.SqlClient.SqlBulkCopy (For this problem can I packaged ATL done by C#? From Visual Studio 2008 \ New Project, I can find "ATL Projects" only under VC++. Is my option a COM server without ATL as indicated in Third Reference below? I am inheriting an old VB.NET COM project but having problem getting it registered, but it must be possible)
PROBLEM 3: Windows 2003 64 bit  any deadend you know?
http://digitalclipart.de/KB/COM/SimpleCOM.aspx
1..2..3 ways of integrating MATLAB with the .NET[^][^]
http://msdn.microsoft.com/enus/library/aa645712(v=VS.71).aspx[^]
dev





hey guys!!!
d frontend of ma project is in VB.net and d processing part is done by matlab...
i want to understand d connectivity between matlab and dotnet...
1.d user would first load an image in d VB.net form.... (which i hav implemented)
i need to implement d follow...
2.d image would be den passed to matlab for processing....
3.after processing matlab will return d output in form of image....
wat shall i do inorder to link matlab n dotnet???? plz guys help me.....thanx in advance....tc....





I spent a while trying to get this to work but noted that the post was originally published in 2003. There is a .Net builder in Matlab, which can be accessed using the command 'deploytool' inside the Matlab IDE. This builds DLLs as well as .Net objects (which can of course be included in your C sharp project). I haven't tried it out properly yet, but hopefully will work ok.





I agree  this article is a little outdated  check the matlab doc for matlab builder NE which is the deployment tool for converting M files to .Net FWK DLLs





hello
Matlab support request  basically, I'm able to call COM (inprocess server) component developed in C# from Matlab  this C# function for example:
(Example http://www.codeproject.com/KB/vbinterop/csCom.aspx)
public int PerformAddition(int a, int b)
{
// throw new Exception("The method or operation is not implemented.");
try
{
return a + b;
}
catch
{
return 0;
}
}
Now my trouble is, I want to:
(a) pass in array of args of mixed types (int, doubles, string, DateTime ... etc, no custom Struct/Classes)
params object[] args
(b) return a 2 dimensional matrix of mixed types (if not possible perhaps thru C# "ref" input variable)
For example,
public int RunStoredProc(string strProcName, ref object[,] oResult, params object[] args)
{
object[,] oResultMatrix = { { "USDHKD", 7.81, 7.82, 7.83, 7.84, 7.85}, {"USDCAD", 1.08, 1.09, 1.10, 1.11, 1.12} };
oResult = oResultMatrix;
return 1;
}
Matlab code would resemble:
h = actxserver('SQLCmdRunnerClass')
strStrategy = 'longOnlyDirectional';
strRegion = 'NA';
nExchgCode = 123;
ResultMatrix = zeros(10,10); << Problem #1 (Predefine ResultMatrix): Also how can I not predefine Matrix dimension
h.invoke('RunStoredProc', 'sp_GetPortfolio, ResultMatrix, strStrategy, strRegion, nExchgCode); << Problem #2
release(h);
Problem #1: If I don't predefine ResultMatrix, The error message (when call invoke) is:
??? Undefined function or variable 'ResultMatrix'.
Problem #2: Now if do predefine ResultMatrix, the error message (when call invoke) is:
??? No method 'RunStoredProc' with matching signature found for class 'COM.SQLCmdRunnerClass'.
Problem #3: I've also failed with this attempt:
public object[,] RunStoredProc(string strProcName, params object[] args)
I have already successfully call simple function within the dll/COM object, for example, "PerformAddtiion" (above). I just need to pass Matrix/Array in and out.
Thanks
dev
modified on Monday, August 3, 2009 12:39 AM





Hi all, I have installed Matlab R2008a and a colleague has provided me with a Ccompiled (R2008b) of an Mfile.
I'm using .net to access that library with no success (I'm given two linker errors back):
 error LNK2019: unresolved external symbol _mxGetPr_proxy referenced in function _main
 error LNK2019: unresolved external symbol _mxCreateDoubleMatrix_730_proxy referenced in function _main).
Do you know if there's any solution to that?
The folders (includes and libraries) are pointing at: development folder, matlab\extern\lib\win32, matlab\extern\include
The source code, basically, is:
#include "stdafx.h"
#include "ect.h"
#include ;
#pragma comment(lib, "libmx.lib")
#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmex.lib")
#pragma comment(lib, "libeng.lib")
#pragma comment(lib, "ect.lib")
void main(void)
{
double takeUpAux[1] = {1.3300};
bool rdo = false;
mxArray *takeUp, *ECTcalc;
takeUp=mxCreateDoubleMatrix(1, 1, mxREAL);
memcpy(mxGetPr(takeUp), takeUpAux, sizeof(double));
ectInitialize();
rdo=mlf_prognosticate_ECT(1, &ECTcalc, takeUp);
ectTerminate();
mxDestroyArray(takeUp);
mxDestroyArray(ECTcalc);
}
However if I include #pragma comment(lib, "mclmcrrt.lib"), the program compiles but when debugging it stops at memcpy(...) because takeUp is pointing to 0x000000 address.
Any idea?
Oscar ... getting mad





Before using your library, my code used a MAT file writing/reading library. My coded wrote a MAT file, executed a command line Matlab instance to process the variables, and then readed the resulting MAT file.
This process could be accelerated if I used Named Pipes instead of actual files.
Thanks for your solution! I think that my former approach will never have the same performance as yours.






Hi!
Did I see right, if i didn't find a possibility to get MatLabpictures as Metafilepict over DDEconnection with Matlab as server?
I think that should be possible over the EngFigureResult, but I'm not sure, how to do it.
If that's right, do anyone have an idea, how to integrate this?
Fabian





HI,
I Created a Windows GUI using Microsoft MFC. This created a .exe file. I want to invoke this GUI in MATLAB. How is this done? Can anyone help me please...





Which matlab version is this? I'm having problem running your test example Image project, and i have ver7.
I suspect the versions is the cause. The error it brings is "unable to load 'libeng.dll'". i even dropped it in system32, nothing.





Uninstall you Mathlab copy.
Then goto Mathlab Website. And read documentation. Installation Guide.
Latest Versions are R2007a / R2007b.
Up to date version is R2008a





Put the <MATLAB root>\bin\win32 folder in your PATH and restart.





Hi,
I have a c++ application which uses Matlab engine to save
data for further use with Matlab. I need to distribute the
application to users that do not have Matlab. Is there a
way tp use Matlab Engine with Matlab Runtime Component ?
How should I change the compilation to do it ?
Thanks,
Ofra





hi.
Read MCR. Part of MatLab doccumentation. DotNet compiler.
When you compile your DLL mathlab library functions. Use setting and click on MCR optionBox for an autoInstallation of your MathLab Generated DLL. on target computer.
hen no need for him to have Mathlab Instaled.
It works fine.





Hi, I assume you are referring to the Matlab Compiler Runtime and the latest documentation (R2012a) states..
[..] you cannot run the MATLAB engine on a machine that only has the MATLAB Compiler Runtime (MCR).
(Source)
From my experience the same is true for older versions.





I'm interested in using it with the CSIM (Circuit Simulator) package.
CSIM is writen in C++ and uses a MEX interface to Matlab.
Can I do this?





hi ,
i am given a .p file which can generate .txt files of some sort from matlab model .
i want to run that from my c#.net application by invoking matlab from my app .
kindly give me step by step solution as i am lost with all the solutions suggested on line .





create an instance in C#.net and call the function or method of .p and this .p file returns someoutput and returns this output to a variable in C#. do the operation u want





kindly explain in detail what instance do i have to create ?





Hi,
Can I use matlab to create a dll file for example to solve a polynomial or do NewtonRophson and then use it in C#.Net.
If it is possible please tell me how. I'll appreciate you alot.
Best Regards





Hi,
I am also interested to know the same. We have to make a webservice which can do optimization and input out put analysis using matlab. Please let me know if you have any idea how this can be done






I've tried to use Com Interface  using library MLapp.
The problem here is that I'm not able to create more than one matlab connection from the same .net session. I do the following:
matlab = new MLApp.MLAppClass();
string Result = matlab.Execute("cd ..\\..\\work");
matlab1 = new MLApp.MLAppClass();
string Result = matlab1.Execute("cd ..\\..\\work");
And here I hoped to get two sessions of matlab, but I always get only one. Moreover, all the execute commands are being executed in the same opened matlab environment.
Any idea?





in the MATExplorer,there are the code to show the structure:
public void RefreshView()
{
mtxView.Items.Clear();
if(!mat.IsOpened)
return;
NamedMatrixCollection mtx = mat.Variables;
foreach(string s in mtx.Keys)
{
MatrixDescription md = mtx[s];
ListViewItem lvi = new ListViewItem(new
string [] { md.Name, md.TypeName, md.Rows.ToString(), md.Cols.ToString()});
mtxView.Items.Add(lvi);
}
}
my question is ,can u tell me ,how to show the date in the matrix?





I have MATLAB Component Runtime 7.2 installed (not with Matlab IDE, just the runtime components)
When using the COM method,
matObject = Interaction.CreateObject("Matlab.Application","")
this line gives the exception
"An unhandled exception of type 'System.Exception' occurred in microsoft.visualbasic.dll
Additional information: Cannot create ActiveX component."
Also when using the Matlab engine method:
engine = MATInvoke.engOpen(null)
This always returns zero. Due to this no other operations are performed.
Do any body know why is the Engine not starting up?
When I was born, I was so surprised I didn't talk for a year and a half.





I cannot find the matrix class which supports direct access to matrices, stored with different formats. I do not think it exists inside MATNET Library...





Emanuele Ruffaldi,I have met the same question.Could you tell me how to solve it?





After studying many useful articles including the above one, I collected some samples codes to make a C# console application. For me, it is enough.
/*
* Launch Matlab, run commands, and retrieve data.
*
* You should Matlab installed.
* You should add MLApp to References by selecting COM  MATLAB Application (version x.x) Type Library.
* You should add Microsoft.VisualBasic by selection .NET  Microsoft.VisualBasic to References.
*
* Environment: MATLAB 7.0 / Visual Studio 2005 / Windows XP SP2
*
* References
* http://www.mathworks.com/support/solutions/data/11B3JH.html?solution=11B3JH
* http://groups.google.co.kr/group/comp.softsys.matlab/browse_thread/thread/4216ae30b064447f/61faffad8e1980a2?lnk=st&q=matlab+invokemember&rnum=1#61faffad8e1980a2
* http://www.codeproject.com/dotnet/matlabeng.asp
* http://www.mathworks.com/access/helpdesk/help/techdoc/ref/index.html?/access/helpdesk/help/techdoc/ref/getfullmatrix.html&http://www.mathworks.com/cgibin/texis/webinator/search?pr=Whole_site&db=MSS&prox=page&rorder=750&rprox=750&rdfreq=500&rwfreq=500&rlead=250&sufs=0&order=r&whole=Whole_site&entire_flag=1&is_summary_on=1&ResultCount=10&query=getfullmatrix&submit=Search
* http://groups.google.co.kr/group/comp.softsys.matlab/browse_thread/thread/373bf10951ca2759/c82bab39c20fbc3e?lnk=st&q=InvokeMember+GetFullMatrix&rnum=2#c82bab39c20fbc3e
* http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/index.html?/access/helpdesk/help/techdoc/matlab_external/f135616.html&http://www.google.co.kr/search?hl=ko&newwindow=1&rls=GGGL%2CGGGL%3A200614%2CGGGL%3Ako&q=MLApp.MLAppClass+matlab+%3D+new+MLApp.MLAppClass%28%29%3B&btnG=%EA%B2%80%EC%83%89&lr=
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using Microsoft.VisualBasic;
namespace ConsoleApplicationMatlabCom
{
class Program
{
static void Main(string[] args)
{
// References
// http://www.mathworks.com/support/solutions/data/11B3JH.html?solution=11B3JH
string path = Directory.GetCurrentDirectory();
// Matlab command
// At the first part of the command, I change working directory to the current directory
string command = "cd " + "'" + path + "'" + ", suf(peaks), print djpeg fig_surf, a = 1, b = [2 3 4], i = [5 6 7; 8 9 10]";
// Get the type info
Type matlabtype;
matlabtype = Type.GetTypeFromProgID("matlab.application");
// Create an instance of MATLAB
object matlab;
matlab = Activator.CreateInstance(matlabtype);
// Prepare input as an object
object[] arrayInput = new Object[] { command };
// Call MATLAB method
// In the following reference, FullMatrix, PutCharArray, and GetCharArray functions
// can be called through InvokeMember(). However, it says GetFullMatrix does not work correctly.
// http://groups.google.co.kr/group/comp.softsys.matlab/browse_thread/thread/4216ae30b064447f/61faffad8e1980a2?lnk=st&q=matlab+invokemember&rnum=1#61faffad8e1980a2
// The result obtained by Execute is just an object (a string). Therefore, one should convert it to numerical values
// to use it his/her codes.
object result;
result = matlabtype.InvokeMember("Execute", BindingFlags.InvokeMethod, null, matlab, arrayInput);
Console.WriteLine(result.ToString());
// Get matrix from MATLAB workspace
// GetFullMatrix() is useful to retrieve workspace numeric variables.
// You don't need to make a parser as for Execute()
// http://www.mathworks.com/access/helpdesk/help/techdoc/ref/index.html?/access/helpdesk/help/techdoc/ref/getfullmatrix.html&http://www.mathworks.com/cgibin/texis/webinator/search?pr=Whole_site&db=MSS&prox=page&rorder=750&rprox=750&rdfreq=500&rwfreq=500&rlead=250&sufs=0&order=r&whole=Whole_site&entire_flag=1&is_summary_on=1&ResultCount=10&query=getfullmatrix&submit=Search
int nrow = 2;
int ncol = 3;
object[] parameters = new object[] { "i", "base", new Double[nrow, ncol], new Double[0] };
bool [] argsCallBack = new bool[4] { false, false, true, false };
// As mentioned above, calling GetFullMatrix() through InvokeMember() does not seem to work.
// In the following reference, a simple workaround method is described.
// http://groups.google.co.kr/group/comp.softsys.matlab/browse_thread/thread/373bf10951ca2759/c82bab39c20fbc3e?lnk=st&q=InvokeMember+GetFullMatrix&rnum=2#c82bab39c20fbc3e
// the poster uses Visual Basic COM binder instead of reflection method.
// Therefore, you need to add "Microsoft.VisualBasic" to references of your project.
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(matlab, null, "GetFullMatrix", parameters, null, argsCallBack);
double[,] data;
data = (double[,])parameters[2];
for (int i = 0; i < nrow; i++)
{
string data_string = null;
for (int j = 0; j < ncol; j++)
{
data_string += data[i, j].ToString();
data_string += " ";
}
Console.WriteLine(data_string);
}
// The code in the following URL should do same works.
// However, in my machine, it crashes with an unhandled exception.
// http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/index.html?/access/helpdesk/help/techdoc/matlab_external/f135616.html&http://www.google.co.kr/search?hl=ko&newwindow=1&rls=GGGL%2CGGGL%3A200614%2CGGGL%3Ako&q=MLApp.MLAppClass+matlab+%3D+new+MLApp.MLAppClass%28%29%3B&btnG=%EA%B2%80%EC%83%89&lr=
}
}
}





I get this:
??? Undefined function or method 'suf' for input arguments of type 'double'.





Hi Mah Jin Khai,
I used mcc to generate the DLL for an m file
But it did not generate any install.bat
also i am not able to add this DLL in C# by using add reference
My basic requirement is i should be able to call a matlab program from C# directly
can you help me with this issue
HemKiran








General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

