This is an expected behavior I guess. An iteration happens on a single worker, out of the “n” workers available. In this iteration if we have 2 function calls then these functions will be executed serially on that worker and simultaneously another worker will handle another iteration. Thus in your case two workers are executing two separate iterations sequentially and arrays from different iterations are getting compared.
Parallelly use calling function
8 次查看(过去 30 天)
显示 更早的评论
I want to use parfor but it doesn't work. Now I found the reason is that I call a function in the loop. In that function, I compared two arrays (the two arrays are generated at the beginning of the loop). However, MATLAB doesn't parallelly compute the calling function. Instead, it starts to compare arrays in different loops. So my question is that how could I use the calling function parallelly, just like I run the programming on different computers?
Thanks
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!