Matpipe:
#!/bin/bash
((tail -f ~/matin | tee >(cat 1>&2)) & cat) | matlab
Writemat
#!/bin/bash
cat $@ | tee ~/matin
Vim function
vmap
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.