MATLAB function block error in Simulink

20 次查看(过去 30 天)
Hi,
I am trying to run a function in Simulink model. I have the function working without any error if I call it in an m-script. However, if I add the same function in MATLAB function block, I have dimension errors.
Why don't I see these errors when I call it in m-script? Is there is a way to debug this?
Thanks

采纳的回答

Abdolkarim Mohammadi
编辑:Abdolkarim Mohammadi 2020-9-24
Unlike m-file functions, MATLAB function block does not apply automatic array expansion. The simplest way to overcome is to define your m-file function as an extrinsic function in the MATLAB function block.
function v = fcn (u) % MATLAB function block
coder.extrinsic ('MATLAB function name'); % m-file function
  6 个评论
Rubeena Parveez
Rubeena Parveez 2020-9-24
Thank you, this works but I read that coder.extrinsic does not support code generation. Is there any other way to do this?
Abdolkarim Mohammadi
编辑:Abdolkarim Mohammadi 2020-9-24
As far as I know, there is no way. As emphasized by documentation and the top contributor of this forum.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by