Hi Abdias,
As per my understanding, you want to make an app in which you can take input of the year from the slider, and highlight that year's part of the plot.
You can consider the attached file which contains an example of the implementation to achieve the required results.
% Value changed function: Slider
function ValueChange(app, event)
value = floor(app.Slider.Value);
app.Slider.Value = value;
x = app.X;
y = app.Y;
plot(app.UIAxes, x, y);
% You can edit the value of range to change the width of
% highlighted part
range = 1;
ptchidx = (x >= value - range) & (x <= value + range);
patch(app.UIAxes, [x(ptchidx) fliplr(x(ptchidx))], [y(ptchidx) zeros(size(y(ptchidx)))], [0.9 0.7 0.5], 'FaceAlpha',0.3, 'EdgeColor','none')
end
For further information on the functions used in the code, kindly refer to the following links: