Monday 17 October 2011

Make Matlab writable by pipes

mkfifo matin

Matpipe:
#!/bin/bash
((tail -f ~/matin | tee >(cat 1>&2)) & cat) | matlab

Writemat
#!/bin/bash
cat $@ | tee ~/matin

Vim function
vmap :call ExecuteMatlab()
function! ExecuteMatlab() range
:'<,'>!writemat
endfunction


Then pipe commands to matin.

This prints stuff sent to matin to the stdin of matlab and also to stderr, as well as able to read from the stdin of the terminal.

Keyword: process substitution - >(....) creates a temporary file in bash and feeds stuff to that process.