Lev - why in your SliderValueChanged callback are you overwriting the Slider with its value? I suggest that you remove this function (or at least the code inside of it)
function SliderValueChanged(app, event)
end
As for the error, it is telling you that you are trying to index into an array with something other than a positive integer or (0 or 1) logical value. I suspect that the slider value is NOT an integer so you will need to ask your self how to convert this number into a valid index for the arrays. For example, your code might look like
function GPSMenuSelected(app, event)
gps1=[app.x;app.y];
plot(app.UIAxes,app.x,app.y,'LineWidth',2);
hold on
sliderValue = ceil(app.Slider.Value);
if sliderValue >= 1 && sliderValue <= length(app.x)
plot(app.UIAxes,app.x(sliderValue),app.y(sliderValue),'b--o',...
'LineWidth',6);
end
hold off
end
I don't know if that is valid for you so please validate before trying it out.
Best Answer