Hello dear forum:
I am working on an battary optimization problem. As part of the problem, an electrical resistance should be dependent on T, C-Rate and SOC. I have a lot of sample values in between which it should be interpolated. Because the optimization problem is designed as a shortest path model, it iterates around 200 million times. My current approach is shown below and is currently very slow due to the interpolation. I used the griddata-command for interpolation.
Is there a faster way? My ideas:
  • Interpolate a lot of values in the first rotation and then only select the closest one etc.
  • Turn the sample values into a function. (I have heard about this but didnt find it).
I am glad for any suggestions!
Thank you and merry easter.
Here my current function:
function R = calculateResistance_neu_neu(R0,I,SOC,T,Q)
T = T;
C_Rate = I/Q;
SOC = SOC;
matrix = [5, 0.5, 0.1, 2.25, 135;
.....
45, 3, 0.8, 1, 60;
45, 3, 0.9, 1, 60];
Multiplikator = griddata(matrix(:,1),matrix(:,2),matrix(:,3),matrix(:,4),T,C_Rate,SOC);
R = R0*Multiplikator;

4 件のコメント

埃博拉酱
埃博拉酱 2023 年 4 月 9 日
Try to set the matrix as persistent. You'd better show more code outside this function. Optimization is hardly possible without your outer code.
Fabian Haslwanter
Fabian Haslwanter 2023 年 4 月 9 日
Thank you. Tried making it persistent. However most of the time is consumed by the interpolation.
Here is the full code. I tried to put in some comments to explain it but it bases on the shortest path method. I hope it's somewhat understandable.
Matt J
Matt J 2023 年 4 月 9 日
Your mfile contains no function called calculateResistance_neu_neu()
Fabian Haslwanter
Fabian Haslwanter 2023 年 4 月 9 日
編集済み: Fabian Haslwanter 2023 年 4 月 9 日
Line 47
I just tried running it and it works for me. Here again with the function. Hope thats what you mean :)
EDIT: Sorry i should have mentioned i have the function in a different file...

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

 採用された回答

Vanshika Vaishnav
Vanshika Vaishnav 2023 年 4 月 12 日

0 投票

Setting the matrix as persistent will resolve the issue, however most of the time will be consumed by the interpolation.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by