How to pass parameters from C # to MATLAB?

I want to pass the image file name as a parameter from C # to MATLAB. Here is what I still have:

MATLAB Code

function out = trial(im)
  O = imread(im);
  G = rgb2gray(O);
  imwrite(G,'output','jpeg');
  out = G;

C # code

private void btn_Browse_Click(object sender, EventArgs e)
{
    openFileDialog1.ShowDialog();
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
        pictureBox1.Image = new Bitmap(openFileDialog1.FileName);
    }
}

When I browse and select an image file (openFileDialog1.FileName), I want to send it as an input parameter to the MATLAB function. How to do it?

+3
source share
1 answer

For an external program to call Matlab, you need to use the Matlab Engine, which is an autonomous part of the Matlab suite. It is not possible to create a C # application and run its code in the Matlab command window.

A description of how to use the Matlab Engine is here (examples are given in C and Fortran).

, , click click.

+2

Source: https://habr.com/ru/post/1710636/


All Articles