I'm trying to use 'MATLAB Function' under 'User-Defined Functions' on Simulink Library Browser to write something like,
function y = sine1(u) %#codegen
global n m g C1 C2 C3
if u(i) <= -g
y(i) = n*u(i)./m + g*n/m;
elseif u(i) >= -g && u(i) <= g
y(i) = C1*sin(pi*u(i)./g+pi)+C2*sin(2*pi*u(i)./g+pi)+C3*sin(3*pi*u(i)./g+pi);
y(i) = n*u(i)./m - g*n/m;
Global variables are called from another m file and u is a vector and other variables are scalar. When I run it, I get this error message: Errors occurred during parsing of MATLAB function 'sine1'(#23).
Does anyone know what is causing this issue? I'm also curious to know what this #23 means. I can't seem to find anything online so far. Any help would be very helpful. Thank you.