0

I am building a Windows Forms Application that uses a MATLAB back end. What is the best, possibly cleanest, way to do this? Furthermore, I need to grab the MATLAB output data and work with it in the Windows Forms program.

What I have done so far:

  • Using the Process class I ran a batch file that calls the MATLAB program:

       Process process = new Process();
       process.StartInfo.FileName = @"----\run.bat";
       process.StartInfo.WorkingDirectory = @"----";
       process.StartInfo.UseShellExecute = false;
       process.StartInfo.RedirectStandardOutput = true;
       process.StartInfo.RedirectStandardError = true; 
    

    Executing Batch File in C#.

I am able to run the script without a problem. However, I cannot receive the output stream from MATLAB. I tried all of the solutions in the link above, but it does not work in my particular situation. I assume this has something to do with MATLAB.

2

1 Answer 1

2

The best way is probably to use the COM interface supplied by Matlab.

You'll need to add a reference to your C# project referencing the Matlab Application, then instantiate an object of type MLApp, which will allow you to call Matlab. For a simple example refer to http://www.mathworks.com/help/matlab/matlab_external/call-matlab-function-from-a-c-client.html.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.