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 次查看(过去 30 天)
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 个评论
Voss
Voss 2021-12-4
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 2021-12-4
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.

请先登录,再进行评论。

回答(1 个)

Shanmukha Voggu
Shanmukha Voggu 2021-12-29
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

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by