MATLAB function block error in Simulink
26 views (last 30 days)
Rubeena Parveez on 24 Sep 2020
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?
Abdolkarim Mohammadi on 24 Sep 2020
Edited: Abdolkarim Mohammadi on 24 Sep 2020
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