spmdIf you run this code you'll be left with two variables in the workspace, y and n. Let's focus on the variable y:
y = zeros(1,100);
for n = labindex:numlabs:100
y(n) = n;
end
end
>> whos yAs you can see we're dealing with a composite object. And what is that? A composite object is pretty similar to a cell array. It has as many elements as the number of labs and each element corresponds to the part of the variable y that is stored in the respective element.
Name Size Bytes Class
y 1x4 1145 Composite
>> yYou can manipulate a composite object in the same way you deal with a cell array. Running the command y{1} will return the vector y as stored in the first lab.
y =
Lab 1: class = double, size = [1 97]
Lab 2: class = double, size = [1 98]
Lab 3: class = double, size = [1 99]
Lab 4: class = double, size = [1 100]
y{1}In our case each lab stores a different portion of the variable. This could not be the case. Various labs can store the same portion of the variable, or no part of it at all.
ans =
Columns 1 through 21
1 0 0 0 5 0 0 0 9 ...
If you want to know in which workers the variable exists just run the function:
>> exist(y)The function exist returns 1 when the variable exists in the respective lab, and 0 otherwise.
ans =
1 1 1 1
There's not much left to say. If you are familiar with cell arrays then then I'm sure you haven't learned anything new. If you didn't then I hope this was enough to get you started.
Cheers.
No comments:
Post a Comment