开发者

Run matlab and excute file.m from website

开发者 https://www.devze.com 2023-02-19 15:45 出处:网络
i m building a website, and i want to run MATLAB file on the server an开发者_开发百科d display the result on web page,

i m building a website, and i want to run MATLAB file on the server an开发者_开发百科d display the result on web page, please if u have any idea how to run matlab from web site tell me

thank u soo much .


This is explained in detail in this guide: http://www.mathworks.com/help/toolbox/compiler/example_guide/brh232k.html

Basically you need to compile your .m file using the Matlab Builder NE and deploy it as a webservice or normal ASPX file. See here for an overview of the deployment scheme.


This might be a terrible hack but perhaps it helps. I have read that you can make an executable from your MATLAB file. If that is so. The following has worked for me when I need a Web Application to execute an executable and show the results. Be warned, the account your web application runs under will need permissions to run the executable.

Once you have made your MATLAB file into an executable you can create a process, redirect its standard output and place that output in a web element (in this example I used a label).

        //Get the path to the executable you wish to run from a setting in web.config
        var executablePath = ConfigurationManager.AppSettings["MATLAB_EXECUTABLE_PATH"];
        //Create a process to execute the executable. Redirecting the output.
        var proc = new Process();
        proc.StartInfo = new ProcessStartInfo
        {
            CreateNoWindow = true,
            ErrorDialog = false,
            FileName = executablePath,
            RedirectStandardError = true,
            RedirectStandardOutput = true,
            Arguments = args,
            UseShellExecute = false //Very important do not leave this out.
        };
        proc.Start(); //Execute the executable.
        lblOutput.Text = proc.StandardOutput.ReadToEnd(); //use the results
        lblErrorMessages.Text = proc.StandardError.ReadToEnd(); //Show any error output from the executable.
0

精彩评论

暂无评论...
验证码 换一张
取 消