MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   MATLAB中的多线程 (https://www.labfans.com/bbs/showthread.php?t=24243)

poster 2019-12-10 20:48

MATLAB中的多线程
 
我已经阅读了MATLAB有关多线程的信息,以及如何在某些函数中内置它的信息。但是,我的要求是不同的。说,我有3个函数:fun1(data1),fun2(data2),fun3(data3)....我可以在这些函数之间实现多线程吗?实际上,我有300多个函数使用大量数据。多线程可以帮助我节省很多时间。请提出命令或我可以进一步研究的内容。谢谢!



[B]回答:[/B]

如果要在不同的处理器上运行一批不同的函数,则可以使用“并行计算工具箱”,更具体地说,使用[URL="http://www.mathworks.com/help/toolbox/distcomp/brb2x2l-1.html"]parfor[/URL]循环,但是您需要将这些函数作为句柄列表传递。

funList = {@fun1,@fun2,@fun3}; dataList = {data1,data2,data3}; %# or pass file names matlabpool open parfor i=1:length(funList) %# call the function funList{i}(dataList{i}); end [B]编辑:[/B]从R2015a开始, matlabpool函数已从Matlab中[URL="http://www.mathworks.com/help/distcomp/release-notes.html?searchHighlight=matlabpool"]删除[/URL] ,您需要改为调用parpool 。



[url=https://stackoverflow.com/questions/4495000]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 14:18

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.