I , I have some long calculation codes written inside my simulink m function and a longif-elseif-else loop that repeatedly uses those same codes, the end result being my program has become cumbersome. In a normal m file, one can use nested function, and simply call the function. That is not possible in embedded matlab codes. I am trying to use coder.extrinsic keyword and call an external m file ( which has the repetitive files) while running my simulink model,unfortunately it gives an error message. Both my test model and my actual model gives an error, mostly that one input is not correct. Here is a sample of the test code in my test mdl file.
if true function [y1,y2] = fcn(u1,u2,u3) %#codegen
coder.extrinsic('-sync:on','test'); x1 = u1*u2; x2 = u1*u2*u3; x3 = u2*u3; y1 = test(x1,x2); y2 = test(x2,x3);end
The test function looks as follows
if true function out = test(a,b) out = a+b;endend
The picture of error message is also attached. I really do not understand what is going wrong and would appreciate any help. I do not have license for Simulink coder so using a S function is not possible.
Best Answer