I have 4 distinct large files I'd like to load into memory simultaneously. The following example is not exactly what I'm doing -- but it illustrates to problem:
matlabpool open local 4
spmd
if labindex==1
R = rand(9,9);
else
R = rand(4,4);
end
end
size(R)
when I copy and paste this into the command prompt, R pops up in my work space. but if i save this to a *.m file, size(R) doesn't evaluate -- it gives me an error that R doesn't exist. I've tried using gather and initializing R as a global to no avail. Any ideas?
R
pops up? You have a semicolon after the lines whereR
is created. I can't replicate what you describe (Matlab R2012b, OS X 10.8.3). The code above runs normally from the command window, a script M-file, and a function M-file.size(R)
prints out every time: a 1-by-4 composite. Did you possibly create a function M-file rather than a script and are trying to accessR
from the command window after running the file? If it was a function then you're right, it is a scoping issue. Functions have their own scope regardless of if they callspmd
or not.