C# call the Matlab function to compute the nonlinear programming problem?
이전 댓글 표시
I just know how to solve a linear programming,but I didn't know how to abou a nonlinear programming. How can I call the Matlab function in the WinForms to solve a nonlinear programming? That means C# pass the required data to Matlab function ,and I didn't know how to pass parameters between C# and Matlab as to solve anonlinear programming. Would anyone give me some examples? Thanks a lot!
답변 (1개)
Kaustubha Govind
2011년 3월 29일
0 개 추천
One option is to start MATLAB up as a COM server from your C# application. The example Calling MATLAB Software from a C# Client describes how you can pass data in and out of MATLAB.
댓글 수: 4
James Bai
2011년 3월 31일
Kaustubha Govind
2011년 3월 31일
You can create a MATLAB script/function to solve the equation (I would recommend first testing your function with some sample data before you try invoking it from .NET). Once you have that ready, you can follow the "Calling MATLAB Software from a C# Client" example to pass in variables required by your function. Additionally, you would use matlab.execute("command to run your script") to run your file.
James Bai
2011년 4월 1일
Kaustubha Govind
2011년 4월 1일
I don't have much experience with non-linear programming - please create another question for that part, so someone else can help you with it. To disable all warnings, you can use "warning off" at the start of your function - i would recommend using "warning on" at the end of the function, to restore the original warning state. You should make your code error-free to be able to successfully obtain results in C#.
Regarding passing data - again, you can simply use PutFullMatrix and GetFullMatrix as described in the cited example. Another alternative that I didn't mention before is MATLAB Builder NE (http://www.mathworks.com/products/netbuilder/), but you may not need it unless you want to run your C# application that does not have MATLAB installed.
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!