Reputation: 324
I successfully made some script to be executed by matlab throught CLI from a web interface of my own. But now, I am trying to get the output of the scripts that we can launch from it.
Does anyone know how to get the values returned by matlab ?
For instance, my script "A.m" is :
a = [3, 6, 9];
I want to get :
a =
3 6 9
My script "B.m" is :
a = [1 2 3 4 6 4 3 4 5]
b = a + 2
plot(b)
grid on
I want to get the result below + the image generated :
a =
1 2 3 4 6 4 3 4 5
b =
3 4 5 6 8 6 5 6 7
I have used these previous topics :
Thanks a lot !
Edit : I call my files this way :
C:\...\matlab\bin> matlab -wait -minimize -nodesktop
-automation -r "run('C:\...\Source2.m');exit;"
Upvotes: 2
Views: 1849
Reputation: 1894
Since I do not have a copy of matlab
I cannot check this but I assume if you run it using command line interface (CLI) it should print output to STDOUT
(i.e. your terminal window when calling it manually).
In this case you should be able to re-direct all text output to a file when calling the script without a need to modify the script itself by
C:\...\matlab\bin> matlab -wait -minimize -nodesktop \
-automation -r "run('C:\...\Source2.m');exit;" > FILEPATH
I hope this is what you want and the above soultion works for you (on Windows it seems to me?).
If you do not understand this solution you might want to read on "output re-direction", it can be very handy in many cases.
If I got your question wrong and you knew about all that, sorry for boring you with basic stuff.
However, when it comes to images, I do not know how to get those.
They clearly won't be sent to STDOUT
along with the text output.
Lacking matlab
I can only guess, but R
's standart behaviour when invoked from the CLI is to create a file called plots.pdf
in the working directory containing all plots.
You could check for a similar file after running the scripts or read the matlab
documentation.
Upvotes: 0