How to detect a value changing in matlab app - numeric edit field

23 ビュー (過去 30 日間)
Tom
Tom 2022 年 8 月 31 日
回答済み: Ankit 2022 年 8 月 31 日
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 件のコメント
Ankit
Ankit 2022 年 8 月 31 日
what kind of operation you would like to execute?

サインインしてコメントする。

採用された回答

Ankit
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 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by