In your code
value = x(get(h,'value'));
you should not expect that the slider value will be constrained to integers, so you should not be using the value as an index into x. You could consider using the value as the location to interp1() x .
In your code
p = line([x(A),x(A)], ylim());
but A is not apparently defined. Is A a function?
In your code
value = x(get(h,'value'));
you have set the slider min to 1 and max to 10 so even if you got an integer value you would be expecting values larger than 1. But you defined
x = 1;
so x is a scalar, not a vector.
