Proper if/else statement in appdesigner
3 次查看(过去 30 天)
显示 更早的评论
In app designer I would like to setup an if/else function that will control the lamp color. I want a value to be within 5% of control value to activate a lamp. I’m trying the below statement but it doesn’t seem to work even when values are exactly the same.
if app.rr_camber_ref.Value >= app.rr_camber.Value*0.95 && app.rr_camber_ref.Value <=app.rr_camber.Value*1.05
app.Lamp_rr_camber.Color='g';
else...
Can someone suggest what would be proper condition statement in this case?
Thank you,
Ted
3 个评论
Cris LaPierre
2022-10-14
What components are you using for app.rr_camber_ref and app.rr_camber? What are typical values for each?
采纳的回答
Jan
2022-10-14
Ref = app.rr_camber_ref.Value;
Value = app.rr_camber.Value;
if abs(Value - Ref) / abs(Ref) < 0.05
app.Lamp_rr_camber.Color='g';
2 个评论
Walter Roberson
2022-10-14
移动:Voss
2022-10-14
I suspect it was more the difference in how the test was calculated, not so much the fact that variables were assigned to.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!