I wrote a Matlab function in Simulink. The compilation process detects that u data is a variable size matrix, but it isn't on my case.
The code is showed below. The error is:
Data 'u' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field.
But when I check the 'Variable Size' option, other problems emerge, because all of my signals presents fixed size.
function u = buffer(d_uf, arrival_time)
m = 1;
Nc = 36;
persistent index u_old d_uf_ready time_old
u_old = zeros(m,1);
d_uf_ready = zeros(Nc*m,1);
index = 1;
time_old = 0;
if arrival_time < time_old
d_u = d_uf_ready(index:index+m-1);
index = index + m;
d_u = d_uf(1:m);
index = 1 + m;
d_uf_ready = d_uf;
u = d_u + u_old;
u_old = u;