Use Python subprocess from Matlab
Matlab system() lacks features needed for blackbox interfacing with executables, including lack of stdin pipe. matlab-stdlib subprocess_run() can exchange data in stdin, stdout, stderr pipes, cwd, environment variables, and more using Java ProcessBuilder. Matlab can also call Python subprocess.