Keep terminal session between system() calls in MATLAB

Viewed 144

MATLAB opens a new session every time system is called. I want to be able to keep the session open and perform several calls to it.

Ideally, this would work:

system('export DUMMY=2');
[~, out] = system('echo $DUMMY');
disp(out)

But it doesn't as each system call is separate. How can I get around this and keep one session running?

The code above can be fixed by using setenv, replacing the first line with setenv('DUMMY', '2');, but I am looking for a more general solution.

1 Answers
Related