-1

I have written a MATLAB function which can send an e-mail. I can call this function from the command prompt, using the following command:

"C:\Program Files\MATLAB\R2017a\bin\matlab.exe"  -r "nameofthefunction;"

When I do this, the MATLAB application opens, and then the function is executed. What I want to do is write a command which would trigger the function (i.e send the e-mail), without opening the MATLAB application.

halfer
  • 19,824
  • 17
  • 99
  • 186
Zed Kay
  • 133
  • 1
  • 2
  • 13
  • 1
    Have a look [here](https://uk.mathworks.com/matlabcentral/answers/102082-how-do-i-call-matlab-from-the-dos-prompt) and also [here](https://stackoverflow.com/questions/26551333/how-to-call-matlab-from-the-command-line-several-times-using-the-same-matlab-in) – Vahe Tshitoyan Jul 05 '17 at 08:37
  • If I am not wrong MATLAB Compiler will run the MATLAB Engine in the background so the function call will take some time before running. – oro777 Jul 05 '17 at 08:58
  • You need to create a MATLAB executable to do this. Check the Matlab Compiler and other relevant options to do this. – Joey Pinto Jul 05 '17 at 08:32

1 Answers1

0

To run a MATLAB function you need to use either (1) the MATLAB environment or you need to (2) convert it to a standalone component. The first is obviously using the MATLAB GUI, as you call it, but maybe it is an option to close it down after using the function

"C:\Program Files\MATLAB\R2017a\bin\matlab.exe"  -r "nameofthefunction; quit;"

For (2) look at the MATLAB Compiler and check whether your function can be converted into a standalone component.

souty
  • 607
  • 3
  • 10