Reputation: 11
I'm trying to use use Matlab to:
Create a new Java process to spawn a 2nd instance of Matlab and then
Write a command to that 2nd instance of Matlab from the first instance of Matlab.
The code seems to run fine, but I don't see anything appear in the command window of the 2nd Matlab instance. What am I doing wrong?
The code I've tried is:
% Start a 2nd instance of Matlab
MatlabProcess = java.lang.Runtime.getRuntime().exec('matlab -nosplash');
pause(20); % I don't know if this pause is really needed.
% Set up a buffered Java stream writer to write to the new Matlab Process
OutputStream = MatlabProcess.getOutputStream();
OutputStreamWriter = java.io.OutputStreamWriter(OutputStream);
OutputBufferedWriter = java.io.BufferedWriter(OutputStreamWriter);
% Write some text to the 2nd Matlab Instance
OutputBufferedWriter.write('pi\n');
OutputBufferedWriter.flush();
Upvotes: 1
Views: 1083
Reputation: 283823
I believe you get either a command window, or use of stdin/stdout, not both, depending on whether the matlab process is interactive.
Upvotes: 1