フィルターのクリア

fzero system of non linear equations

7 ビュー (過去 30 日間)
Bastian  Andersen
Bastian Andersen 2017 年 7 月 7 日
回答済み: Prashant Arora 2017 年 7 月 18 日
Hi
I am trying to solve a system of non linear equations, which is embedded in a function run by a ODE solver. At the current point I am doing it by a for loop, however the computation time is really high (around real time of 10+ hour dynamic simulations), so I would like to bring it down. I've found this step to be very time consuming
For the current simulations par.NT = 13, size(ics) = [13,3], size(xn) = [13,2], size(par.Tb) = [1,2] and I do initialize the variables TB and y. yfun is a function which is called (which calls various other functions)
for n = 1:par.NT
TB(n)=fzero(@(T) sum(yfun(ics,T,par,n))-1,sum(xn(n,:).*par.Tb));
y(n,:) = yfun(ics,TB(n),par,n);
end
Do you have any tips on making this faster? I have been trying to vectorize the loop in various ways, use arrayfun, fsolve... but I can't seem to increase the speed. I do submit my code to HPC clusters. Using parfor decreases the speed drastically.

回答 (1 件)

Prashant Arora
Prashant Arora 2017 年 7 月 18 日
Hi Bastian,
Which part of the for loop is more expensive? Have you tried profiling the yfun function? I believe it takes a structure argument, which can sometimes increase computation time to get fields.

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by