colon operation (:) causes parfor to fail on cell array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Marshall
am 28 Mär. 2013
Kommentiert: Sergio Santos
am 16 Feb. 2015
The following code causes Matlab to throw subscript assignment error:
s=cell(1,20);
parfor i = 1:20
s{:,i}=1;
end
However, when the colon operator is replaced with a 1, there is no error:
s=cell(1,20);
parfor i = 1:20
s{1,i}=1;
end
My guess is this involves a slicing issue somehow. Any insights?
1 Kommentar
Sergio Santos
am 16 Feb. 2015
There is a solution to this. Reshaping whatever you want to send to parfor and turning it into a single column or raw vector. Also make a vector to store the length of each vector you reshape. Then when the operation is finished reshape back into matrix form. Shaping and reshaping is very fast and can be fastly done by a single worker, i.e. no need parallel computing.
Weitere Antworten (2)
Cedric
am 28 Mär. 2013
Bearbeitet: Cedric
am 28 Mär. 2013
It has a priori nothing to do with PARFOR; the expression involving the colon on the left hand side is a comma separated list (CSL), so you cannot have the scalar 1 on the right hand side. Try it with a simple FOR loop and there will be no difference.
I don't know exactly what you want to do with that, but I guess that it is something like
s(:,i) = {1} ;
7 Kommentare
Cedric
am 29 Mär. 2013
Thank you for the update! I will think about it a bit more about it and perform a few tests on my side.
Ben
am 12 Apr. 2013
please tell us they working on a patch. i've come across this bug too now in 2013a
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!