How to run two independent functions simultaneously?
이전 댓글 표시
Hi.I have two functions for creating numbers.lu and lu1(similar to lu).lu 's out put is matrix with 4 columns (rows depend on inputs (same for lu1) )and i have dual core CPU.(numbers in each function is related, but two functions are Independent).
function Y=lu(a,b,c,d,e,k)
[T,Y]=ode45(@rigid,[0 e],[a b c d]);
function dy=rigid(t,y) %#ok<INUSL>
dy=zeros(4,1);
dy(1)=36*(y(2)-y(1))+y(4);
dy(2)=-(y(1)*y(3))+20*y(2);
dy(3)=y(1)*y(2)-3*y(3);
dy(4)=y(1)*y(3)+k*y(4);
end
end
I want to using parallel computing for my two functions by using this code
matlabpool ('open',2);
parfor i = 1:2
if i == 1
xc1=lu(0.10001,0.8,12,0.2,1138,1.2);
else
xc2=lu1(3,0.40001,9,0.7,1010,3.25)
end
in normal code xc1 is matrix with this size[91713 4](same for xc2). is it true way for parallel computing for two functions ? Importantly,how can I using xc1 and xc2 in other parts of my code?
댓글 수: 1
Matt J
2013년 9월 15일
lu() is the name of a pre-existing MATLAB function. It might be wise to choose a different name.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!