The compiler cannot determine the type and size of the outputs of extrinsic functions. Therefore, the compiler will be forced to keep it "MATLAB type" (AKA an mxArray
). The only thing you can do with an mxArray
in Embedded Matlab, is pass it onto another extrinsic function, but you cannot assign it to anything directly.
You'll have to tell MATLAB the type and size of the extrinsic function's output before calling the extrinsic function. You can do this by pre-alocating the variable with the same type and size of the (expected) output.
So, for your square wave:
function y = fcn(~)
%#eml
eml.extrinsic('square', 'linspace');
a = 1;
dc = 50;
f = 2*pi* (6908:1:9856);
% Pre-allocate
t = f;
% THEN assign
t = linspace(0, 1, numel(f));
% pre-allocate
y = t;
% THEN assign
y = a*square(f.*t, dc);