Using .mexw64 in a Matlab function

27 views (last 30 days)
Ana Fernandez Guillamon
Ana Fernandez Guillamon on 13 Nov 2015
Answered: Shruti Sapre on 17 Nov 2015
I'm trying to simulate a Rankine Cycle in Matlab. To calculate the water properties, I'm using the coolprop package
I wrote a script (see below) and it works perfectly. Now, I want to rewrite it into a Matlab function in orden to simulate the cycle with the Simulink block MATLAB function, but it doesn't work: "Only MATLAB files are supported for code generation. Unsupported file extension 'mexw64' for C:\....".
What can I do?
Here's the script I want to rewrite into a function:
clear all
close all
addpath('C:\Program Files\MATLAB\R2015b')
% 1:
P1 = 8e6
Q1 = 1
H1 = CoolProp.PropsSI('H','P',P1,'Q',Q1,'Water')
S1 = CoolProp.PropsSI('S','P',P1,'Q',Q1,'Water')
T1 = CoolProp.PropsSI('T','P',P1,'Q',Q1,'Water')
% 2:
display('Propiedades del agua a la entrada del condensador')
S2 = S1
P2 = 0.008e6
T2 = CoolProp.PropsSI('T','P',P2,'S',S2,'Water')
H2 = CoolProp.PropsSI('H','P',P2,'S',S2,'Water')
% 3:
P3 = P2
Q3 = 0
H3 = CoolProp.PropsSI('H','P',P3,'Q',Q3,'Water')
S3 = CoolProp.PropsSI('S','P',P3,'Q',Q3,'Water')
T3 = CoolProp.PropsSI('T','P',P3,'Q',Q3,'Water')
% 4:
S4 = S3
P4 = P1
H4 = CoolProp.PropsSI('H','P',P4,'S',S4,'Water')
T4 = CoolProp.PropsSI('T','P',P4,'S',S4,'Water')
Wt_m = H1 - H2;
Wp_m = H4 - H3;
Qin = H1 - H4;
Wc = 100e6*3600;
nu = 100 * (Wc/Qin)

Answers (1)

Shruti Sapre
Shruti Sapre on 17 Nov 2015
Hi Ana,
The below link may be helpful to resolve the issue. The functions may need to be declared using coder.extrinsic since the coolprop package seems to use mex files:
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by