This is the code belonging to the Matlab Function Block:
function k = pure_p_I(u)
persistent K_ANT;
if isempty(K_ANT)
% zero the counter on first call only
K_ANT = uint16(1);
k = uint16(0);
end
long = uint16(1551); % +1 en long para garantizar el 2º for
x_camino = u(1:long);
y_camino = u(long+1:2*long);
x_vehiculo = u(2*long+1);
y_vehiculo = u(2*long+2);
L = u(2*long+3);
dist=sqrt( (x_camino-x_vehiculo).^2+(y_camino-y_vehiculo).^2 );
dif = abs(dist-L);
dif_delante = dif;
k = K_ANT;
for i = k:long-1
dif_delante(i-k+1)=dif(i);
end
for i = 1:k
dif_delante(long-i+1) = 700;
end
How to fix this??
[valor,indice] = min(dif_delante); %indice returned as 'double'
k = indice + k -1;
K_ANT = k;
end