How can I take two inputs from the same variable

Hi good day to all of you, I'm currently working on an app to plot a graph based on certain value inserted. For value fo, the user have choice to use the slider to select the values they want or input their own values within the limit of 4 to 36. When it comes to the coding part, how can I take either both values and yet assign to the same variable which is fo, so far I've assigned fo to both of them but one of it doesn't work, is there a better way to do this ?

 채택된 답변

Matt J
Matt J 2021년 5월 29일
편집: Matt J 2021년 5월 29일

0 개 추천

When the Slider is moved, its callback will be invoked. You should set the EditField value in the callback to keep them consistent. Similarly, when then EditField callback is invoked, you should adjust the Slider values.

댓글 수: 8

uhh can you explain further?
Matt J
Matt J 2021년 5월 29일
편집: Matt J 2021년 5월 29일
Have you written any callbacks for your app components?
If not, how are you executig the plot?
so far I did these two callbacks for my input value and slider value, these two belong to fo variable for my plotting of graph, so what should I write fo equals to what ?
Matt J
Matt J 2021년 5월 29일
I cannot copy/paste your code (because it's an image).
(GRAPH)
fo = ?
w = app.EditField.Value;
wn = app.nEditField.Value;
t = 0:1:300;
xt = ((2.*fo)/(wn^2-w^2)).*sin(((wn-w)/2)*t) .*sin(((wn+w)/2)*t);
plot(app.UIAxes, t, xt,'b-^');
(INPUT)
latestvalue = event.Value;
app.SelectValueSlider = latestvalue;
(SLIDER)
latestvalue = event.Value;
app.InputValueEditField = latestvalue;
app.SelectValueSlider.Value = latestvalue;
app.InputValueEditField.Value = latestvalue;
I suggest using one callback function for both objects. You can use the event input to determine which object was changed and the function will merely update the other object.
thanks for the help! I got it now

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

2021년 5월 29일

댓글:

2021년 6월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by