How to detect a value changing in matlab app - numeric edit field
24 views (last 30 days)
Show older comments
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!
1 Comment
Accepted Answer
Ankit
on 31 Aug 2022
@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 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!