User`s guide
11 Functions — Alphabetical List
11-100
Examples
Find the rank of magic squares. Access only the local portion of a codistributed array.
r = zeros(1, 40, codistributor());
for n = drange(1:40)
r(n) = rank(magic(n));
end
r = gather(r);
Perform Monte Carlo approximation of pi. Each worker is initialized to a different
random number state.
m = 10000;
for p = drange(1:numlabs)
z = rand(m, 1) + i*rand(m, 1);
c = sum(abs(z) < 1)
end
k = gplus(c)
p = 4*k/(m*numlabs);
Attempt to compute Fibonacci numbers. This will not work, because the loop bodies are
dependent.
f = zeros(1, 50, codistributor());
f(1) = 1;
f(2) = 2;
for n = drange(3:50)
f(n) = f(n - 1) + f(n - 2)
end
See Also
for | numlabs | parfor