I have three inputs into a Matlab Function block in my Simulink Model. The inputs consist of a 1D array thetaArray and two variables currentIndex and trackingError. The Matlab Function block will output two variables called newIndex and theta.
What would be an ideal way to use the newIndex variable as my new input into the Matlab Function block?
Here is the image of my Simulink Model
And here is the code for the Matlab Function Block in the model:
function [newIndex,theta] = arraySelector(thetaArray,currentIndex,trackingError)
if currentIndex < length(thetaArray) && trackingError <= 0.00002
newIndex = currentIndex + 1;
else
newIndex = currentIndex;
end
theta = thetaArray(newIndex);
end
Thank you in advance.