Strange Error!..... Error while obtaining sizes from Mex-sfunction (in simulink)

5 ビュー (過去 30 日間)
Arsalan
Arsalan 2012 年 11 月 17 日
コメント済み: Viren 2013 年 12 月 3 日
Hi!I need your help. I generated C-mex file from my m-function code (where i used "assert" to define class and size of my input parameters) sucessfully using CODEGEN. Now i want to use my c-mex function in Simulink for RTW.
So, for that i added a S-function block and gave it my function name in "S-function name" place. My code required 11 inputs (1 matrix,9 vectors and 1 constant).Which i was trying to input my s-function block in "S-function parameters" but it was not accepting it and continously giving following error message
"Error due to multiple causes--- Error while obtaining sizes from Mex S-function 'xcxc_mex' in "s-function ----11 inputs required for entry point 'xcxc' ".
I was using generated mex-c function in matlab command window sucessfully with same parameters (variables in workspace).

採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 11 月 19 日
S-functions are a special kind of MEX-function which have a specified interface that the Simulink engine uses to interact with it. The generic MEX-file generated by MATLAB Coder ("codegen" command) does not generate the required interface. Instead, I would recommend directly using your MATLAB code in Simulink from a MATLAB Function block, which automatically generates a MEX-function from your MATLAB code and interfaces it with the Simulink engine.
  4 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 11 月 26 日
Arsalan: Please consider submitting an enhancement request via MathWorks Tech Support team for MATLAB Coder to generate an S-function along with a TLC-file for a MATLAB function.
Viren
Viren 2013 年 12 月 3 日
Hi Kastubha, Any advice for those of us who MUST convert their 'matlab s function' block into a 'CMEX' file? I have this weird bug where I have two copies of one component in the model (I'm simplifying a bit). When I use a CMEX version of the same code, no problemo, but with the matlab sFunction block I get an error.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by