Hi Daniel,
thanks for the response. I actually tried all these things you said because I was thinking something might be wrong with the echoed numbers, but everything seemed to be fine. In the terminal it even worked with extra spaces. So it seems to come down to just the 3dUndump command being called from within matlab or from the terminal. The way I've set it up now is that my matlab script just produces a number of lines that I can copy into the terminal so that I can make the ROIs that I need.
I source the bashrc since it has the paths set to my AFNI commands...
I'm not that familiar with AFNI yet, I just started using some of its commands. Which functions should I be looking into in the AFNI matlab library?