How to detect a value changing in matlab app - numeric edit field
27 次查看(过去 30 天)
显示 更早的评论
Dear Community,
I am currently working on a MatLab app and i am changing the value of a numeric edit field by using a matlab function. Everytime the value changes, i want to execute an operation.
I tried to do it with a ValueChanged Callback, but i figured that it doesn´t work if you dont manually change the value of the edit field. Does anyone know how to detect a changed value if it isn´t changed manually but by another function?
I hope my Problem is clear. Thanks for helping in advance!
采纳的回答
Ankit
2022-8-31
@Tom: I have created one simple example for you.
In this example when the EditField values are changed I am doing different operations like addition, multiplication and division. EditField values i am changing from a function named "startSimulation(app)"
function startSimulation(app)
i = 0;
while i<=10 && app.stop_sim == false
app.display.Value = num2str(i);
pause(0);
displayValueChanged(app)
i = i + 2;
end
end
As I am not aware about your operations, you can imagine similar to yours.
I created a displayValueChanged function and then added to the Callbacks of EditField and Output.
% Value changed function: Output, display
function displayValueChanged(app, event)
value = app.display.Value;
switch value
case '2'
app.Operator.Text = '+';
app.Output.Value = app.A.Value + app.B.Value;
case '4'
app.Operator.Text = '*';
app.Output.Value = app.A.Value*app.B.Value;
case '10'
app.Operator.Text = '/';
app.Output.Value = app.A.Value/app.B.Value;
end
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!