Rewrite "randsample" function, but a variable is indexed, but not sliced
1 view (last 30 days)
Show older comments
Hi there. I'm new in Matlab parallel computing and confused by the Classification of Variables.I try to rewrite the function randsample in a simple way as following,
A=rand(1,36);
parfor t=1:n
index=randperm(36,6);
x=A(index); %=randsample(A,6);
......
However,here the matrix A was labeled as a variable indexed but not sliced. How can I slice A? Thanks a lot.
0 Comments
Accepted Answer
Edric Ellis
on 15 Jul 2014
It's OK to have variables that are "indexed but not sliced" - that warning is trying to tell you that you might be transferring more data than necessary. A variable that is "indexed but not sliced" becomes a broadcast variable, and the whole value must be sent to each worker (for sliced variables, each worker only gets sent the portion it needs to operate on).
In your case, "A" is small, so I would ignore the warning.
0 Comments
More Answers (0)
See Also
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!