In order to gather the individual components of the composite variable into a single array in the MATLAB base workspace, the following modifications must be done to the code:
1) The composite variable should be indexed starting from 1 on every lab. This is because every lab has its own local copy of the variable. Those labs do not know anything about where their work belongs in the whole array, so construct each individual array without taking indexing into account.
2) The final line of the SPMD block should be:
result = gcat(var,2,1);
Where var is the composite variable. This is a global concatenation of all OUTPUT variables, storing the result at lab index 1.
3) After the SPMD block, add the following code:
output = result{1};
This takes the globally concatenated values stored in 'result' and moves them into the base workspace in the variable 'output'.
Best Answer