Using .mexw64 in a Matlab function

조회 수: 7 (최근 30일)
Ana Fernandez Guillamon
Ana Fernandez Guillamon 2015년 11월 13일
답변: Shruti Sapre 2015년 11월 17일
Hi,
I'm trying to simulate a Rankine Cycle in Matlab. To calculate the water properties, I'm using the coolprop package http://www.coolprop.org/coolprop/wrappers/MATLAB/index.html#matlab.
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
clc
close all
%COOLPROP
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')
% MORE
Wt_m = H1 - H2;
Wp_m = H4 - H3;
Qin = H1 - H4;
Wc = 100e6*3600;
nu = 100 * (Wc/Qin)

답변 (1개)

Shruti Sapre
Shruti Sapre 2015년 11월 17일
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!
-Shruti

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by