Increasing lsqcurvefit/nlinfit speed

4 ビュー (過去 30 日間)
Raghav Poddar
Raghav Poddar 2024 年 3 月 6 日
コメント済み: Matt J 2024 年 3 月 6 日
Hi,
I'm looking to increase the speed with which lsqcurvefit is running in my code. The "fitting function" attempts to find a solution by using a lookup table, who's axes are some of my free paramters. I suspect speed is taking a hit because my table is almost 3GB. Right now, I'm sending the table to the anonymous function instead of loading it within the function each iteration (see below - "crossSecSimC2H4" is the database).
[estimCustomCSec(i,:),resnorm,residCsec,~,~,~,Jac] = lsqcurvefit(@(freeParamsC,waveExperiment)fitCustomCrossSecData...
(freeParamsC,waveExperiment,numDens(i),L,absLaser3(:,i,1),bCoeffC2H4,bCoeffCH4,xC2H4range,xCH4range,crossSecSimC2H4...
,crossSecSimCH4,waveExperiment,waveDatabase),freeParamsC,waveExperiment,absLaser3(:,i,1)',[],[],options);
Am I losing speed because even "sending the file" to the function takes long? Or is there no copying of data, in which case the fitting process itself is computationally expensive?

採用された回答

Matt J
Matt J 2024 年 3 月 6 日
編集済み: Matt J 2024 年 3 月 6 日
It would definitely be faster to attach the table as an external variable to an anonymous or nested function, than to freshly load it from disk every iteration.
The slow-down might be coming from the time required for table-lookup. A direct computation can sometimes be done entirely within the CPU and its cache, whereas a lookup process, especially in a table that size, would require frequent RAM access.
  2 件のコメント
Raghav Poddar
Raghav Poddar 2024 年 3 月 6 日
I see, that makes sense. Thanks!
Matt J
Matt J 2024 年 3 月 6 日
You're welcome, but if your question is resolved, please Accept-click the answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by