How to use mex files in MATLAB Function block?

Hi,
I am using ammonia-water thermodynamic properties in MATLAB using routines in C. When modelling dynamic systems in Simulink, I need to repeatedly call these property routines. I was using Matlab Interpreted Function Block till now. Lately, I read that replacing these with MATLAB Function block can speed up the simulations. But, when I call the property routines from within the MATLAB Fcn Block, I get an error. The code inside the block looks like this, with u1,u2,u3 being the different input properties.
function y = fcn(u1,u2,u3)
%#codegen
y = XNH3H2O('TPQ_H',u1,u2,u3);
The errors I get are:
1. Only MATLAB files are supported for code generation. Unsupported file extension 'mexw64' for 'D:/Work/XNH3H2O.mexw64'.Function'MATLAB Function' (#49.41.66), line 3, column 5:"XNH3H2O('TPQ_H',u1,u2,u3)"Launch diagnostic report. (coder error)
2. Error in port widths or dimensions. Output port 1 of 'Function_Test_2/MATLAB Function/u2' is a one dimensional vector with 1 elements. (block error)
3.Errors occurred during parsing of MATLAB function 'MATLAB Function'(#48) (Block error)

回答(1 个)

类别

帮助中心File Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by