How can I make a slider from App Designer change the background of a shape which is loaded from a text file, whilst moving it?

13 views (last 30 days)
How can I make a slider from App Designer change the background of a shape which is loaded from a text file, whilst moving it?
  6 Comments
Voss
Voss on 4 Dec 2021
I'm not sure what that for loop is supposed to do. It looks like the entire loop can be replaced with this line:
fill(app.Canvas, coordinates_x, coordinates_y, cName{1+changingValue});
and it'll do the same thing. (Note that the code inside the loop doesn't depend on the loop index ind or the variable color in any way, so it will just do the same thing over and over several times.)
Regardless, the fact that the fill is always yellow indicates that changingValue is always 0 (or at least it is never 1, 2, or 3). Perhaps print the value of changingValue to the command line from within the callback and make sure you get the values you expect when interacting with the slider.
Adam Danz
Adam Danz on 4 Dec 2021
I suggest using a discrete knob since you're referencing a discrete list of colors. Alternatively, see this answer to learn how to make a continuous slider behave as if it were discrete.

Sign in to comment.

Answers (1)

Shanmukha Voggu
Shanmukha Voggu on 29 Dec 2021
Hi,
The above problem can be solved by using
2)As Adam said try this to make a continuous slider as if it were discrete
3)If you are dealing with integers as ticks try rounding to nearest integer while sliding.
Refer to the this for more information

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!