How can I create an interaction between a Slider and a Edit Field (Numeric) in Matlab App desginer? That if I change one the other one is also changing. Any idea? and example that I can learn from?
Asked
Active
Viewed 624 times
0
-
You need to use the callback of the slider to update the edit field and the callback of the edit field to update the slider. Also, don't forget to put anti-recursion measures in place. – Dev-iL Aug 05 '20 at 16:44
-
What do you mean by anti-recursion measures? – elyraz Aug 06 '20 at 10:35
-
If you change the value of a control from the callback of another control, this will trigger, in some cases, the callback of the first control which then updates the second control, which calls its callback ... etc. You can avoid this using the [`Interruptible`](https://www.mathworks.com/help/matlab/ref/matlab.ui.figureappd-properties.html#bu4i700-1_sep_shared-Interruptible) property of the control, but one can also use `persistent` variables for it, and perhaps there are other ways. – Dev-iL Aug 06 '20 at 11:21
1 Answers
0
Quite simple, suppose u have slider called sliceSelect and (in my case spinner) called sliceSelectNumber
if u change value using slider, u can change spinner value like this:
app.sliceSelectNumber.Value = app.sliceSelect.Value;
if u want to change minor ticks in slider depending on input in spinner, u can do it like that:
app.sliceSelect.Value = app.sliceSelect.MinorTicks(app.sliceSelectNumber);
I hope this helped u a little bit, although this question is old :D for more info see: https://uk.mathworks.com/help/matlab/creating_guis/write-callbacks-for-gui-in-app-designer.html

Ondra Burkot
- 13
- 2