필터 지우기
필터 지우기

alternative way of calling Coolprop every sampling time in simulink

조회 수: 7 (최근 30일)
Seungho Rhee
Seungho Rhee 2023년 2월 3일
답변: Rasmita 2023년 2월 16일
Hello all,
I am using Coolprop for humid air properties in Simulink with Matlab function block. It is working well without any error, but it's too slow. I guess it is calling Coolprop from python library every sampling time, and it makes simulation slow. Here is how I use the Coolprop on my code below.
function y = matlabfunc(input1, input2, input3)
coder.extrinsic('py.CoolProp.CoolProp.HAPropsSI');
y = py.CoolProp.CoolProp.HAPropsSI('Vha','Hha',input1,'P',input2,'RH',input3);
end
Is there any alternative way to use Coolprop with faster speed? For example, calling Coolprop only one time before simulation starts, load it into workspace or somewhere, and use it.
Thanks!

답변 (1개)

Rasmita
Rasmita 2023년 2월 16일
Hi Seungho,
It is my understanding that, you want to run above mentioned function only one time before simulation.
For this, you can add this function content in 'startFcn' callback of the model.
For this, go to Model Properties -> Callback Tab -> startFcn.
It will be called once before the simulation starts.
For more information on model callbacks, refer to this documentation page: model_callbacks.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by