Is there a way to run many anonymous functions simultaneously?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
KieranSQ
am 12 Mär. 2021
Kommentiert: KieranSQ
am 15 Mär. 2021
Hi All,
I have a problem where I need to evaluate 18 anonymous functions before combining them into three variables. This is incredibly slow and painful at points so I was wondering whether there is a way to run these simultaneously (on an 8 core desktop and cluster)?
The reason we have so many functions is we are evaluating our test problem exactly through integration. We plan to create some numerical quadratures in the near(ish) future but need to be sure our method works well first for our test cases. An example of my code is below:
Here all the f_i's are integrals in space and time for an arbitary function.
if conditions == 1
Tf1_1 = f1_1(arg1, arg2, arg3);
Tf1_2 = f1_2(arg1, arg2, arg3);
Tf1_3 = f1_3(arg1, arg2, arg3);
Tf1_4 = f1_4(arg1, arg2, arg3);
Tf1_5 = f1_5(arg1, arg2, arg3);
Tf1_6 = f1_6(arg1, arg2, arg3);
Tf2_1 = f2_1(arg1, arg2, arg3);
Tf2_2 = f2_2(arg1, arg2, arg3);
Tf2_3 = f2_3(arg1, arg2, arg3);
Tf2_4 = f2_4(arg1, arg2, arg3);
Tf2_5 = f2_5(arg1, arg2, arg3);
Tf2_6 = f2_6(arg1, arg2, arg3);
Tf3_1 = f3_1(arg1, arg2, arg3);
Tf3_2 = f3_2(arg1, arg2, arg3);
Tf3_3 = f3_3(arg1, arg2, arg3);
Tf3_4 = f3_4(arg1, arg2, arg3);
Tf3_5 = f3_5(arg1, arg2, arg3);
Tf3_6 = f3_6(arg1, arg2, arg3);
end
%Combining the integrals
loc_f1 = Tf1_1 + Tf1_2 + Tf1_3 + Tf1_4 + Tf1_5 + Tf1_6;
loc_f2 = Tf2_1 + Tf2_2 + Tf2_3 + Tf2_4 + Tf2_5 + Tf2_6;
loc_f3 = Tf3_1 + Tf3_2 + Tf3_3 + Tf3_4 + Tf3_5 + Tf3_6;
Any tips or ideas would be appreciated!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!