Sliced scalar assignment in parfor
2 次查看(过去 30 天)
显示 更早的评论
The following code
A=rand(10);
parfor j=1:10
A(:,j)=1;
end
gives me the following error
Error using test (line 5)
Subscripted assignment dimension mismatch.
Caused by:
Subscripted assignment dimension mismatch.
It seems that you cannot do scalar assignment with parfor sliced variables? If not, is this documented somewhere? I know sliced variables must maintain a constant shape, but scalar assignment does not violate this.
0 个评论
采纳的回答
Edric Ellis
2013-12-11
编辑:Edric Ellis
2024-1-4
Unfortunately, this is a limitation of PARFOR. The only workaround for MATLAB releases prior to R2019b is not to use scalar expansion like that. The limitation was removed in R2019b.
3 个评论
Edric Ellis
2024-1-4
Just updated this ancient answer because I just realised the limitation was removed ages ago...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!