I have 3 variants each with a different number of options and want to score these. So at the moment I have a code which looks as follows:
for n = 1:numel(variant1)
[y1_v1,y2_v1]=calcscoreV1(x1_v1,x2_v1)
end
for n = 1:numel(variant2)
[y1_v2,y2_v2]=calcscoreV2(x1_v2,x2_v2)
end
for n = 1:numel(variant3)
[y1_v3,y2_v3]=calcscoreV3(x1_v3,x2_v3)
end
As these three for loops and their respective functions used are independent of each other, I was wondering if it is perhaps possible to run all 3 loops simultaneously to save computational time?
Thanks in advance.

 채택된 답변

Jan
Jan 2018년 12월 19일

0 개 추천

parfor k = 1:3
if k == 1
for n = 1:numel(variant1)
[y1_v1,y2_v1]=calcscoreV1(x1_v1,x2_v1)
end
elseif k == 2
for n = 1:numel(variant2)
[y1_v2,y2_v2]=calcscoreV2(x1_v2,x2_v2)
end
else % k == 3 and default:
for n = 1:numel(variant3)
[y1_v3,y2_v3]=calcscoreV3(x1_v3,x2_v3)
end
end
end
Of course the outputs y1_v1 etc. must be store in a meaningful way.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2018년 12월 19일

댓글:

2018년 12월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by