Sending DOS command to execute Matlab Function and getting the output back to DOS

1 view (last 30 days)
Michel
Michel on 30 Sep 2014
Commented: Alberto on 3 Oct 2014
Hello,
I need to have a command be sent via DOS to execute a script/function. I'm already able to do this and it opens Matlab and shows the result of the function through the Matlab Command Window. I was wondering if there was a way to display the output in DOS command prompt?
thank you and I'd greatly appreciate the help.
  2 Comments
Michel
Michel on 2 Oct 2014
Hi Geoff and thanks for your comment.
The answer to your first question is actually both. What I am actually doing is sending DOS commands to Matlab via Labview. In a top level I'm controlling instruments via Labview and our Design team uses Matlab scripts for tests, so I wanted to combine both of these worlds. As such, I am sending to execute matlab scipt command via DOS through Labview, but in doing so, I have no feedback, I do get the response, but it is logged in Matlab Command Window.
Thanks! yes, I actually got as far as using -logfile command in DOS to save the result. I was hoping there was something I could use to get the result back to DOS, then the result would therefore be much easily ex tractable and used for other means. I have to think of how to read from file in Labview, I could do this, but that's more code and alterations to our current existing one that I am trying to avoid.
Thanks again for your input! Michel

Sign in to comment.

Answers (1)

Alberto
Alberto on 1 Oct 2014
You have the command 'dos' so u can interpret some DOS command line, and catch the result of it. I extracted a few lines in the help of Matlab:
dos command
status = dos('command')
[status,result] = dos('command')
[status,result] = dos('command','-echo')
As an example:
[s, w] = dos('dir');
Is is what you needed? Good Luck
  2 Comments
Alberto
Alberto on 3 Oct 2014
With the instruction dos('dir') you can extract all files you have. Later, you can select which of them to use according to your own criteria. The selection can be done using regular expressions.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!