use the same result in different callback in matlab app desinger

2 次查看(过去 30 天)
hello,
I am problem that i solved using the app desiner in two step calculation but the second calculation depend on the first one each of them in edit field numeric
so how can I callback the first numeric field value to the calculation of second nuemric field
for example
a=5
b=6
c=5
x1=a*b; % this is in the first nuemricafield.value
then in second numerical field
x2=x1^c in second nuemric field
so how can i express the x1 value of first numerica field in app desinger
Thank u

采纳的回答

Voss
Voss 2022-3-24
Let's say the first NumericEditField is called EditField1 and the second one is called EditField2, and their ValueChangedFcns are called ValueChangedFcn_EditField1 and ValueChangedFcn_EditField2, respectively.
In general, you can get or set any NumericEditField's value wherever you need to by referring to app.EditField1.Value or app.EditField2.Value (or whatever they are called in your app).
So, in this situation, in the second NumericEditField's ValueChangedFcn, you can get the value of the first NumericEditField:
function ValueChangedFcn_EditField2(app,evt)
x1 = app.EditField1.Value;
% now do whatever you need to do with x1
end
And you also might update EditField2's Value whenever EditField1's Value changes:
function ValueChangedFcn_EditField1(app,evt)
x1 = app.EditField1.Value;
c = 5;
x2 = x1^c;
% set EditField2's Value to x2:
app.EditField2.Value = x2;
end
  6 个评论
Voss
Voss 2022-3-24
Take a look at the attached .mlapp file. In that app, when EditField1 changes, EditField2's Value is set to the fifth power of EditField1's Value; when EditField2's Value changes, nothing else changes.
Try to compare the relevant parts of your app wth this app and see if there is anything different between the two that might explain why your app doesn't seem to update when it should.
If that doesn't work, can you attach your .mlapp file (and I'll take a look at it)?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by