MATLAB Answers

Previous Value of Numeric Edit Field

조회 수: 14(최근 30일)
John Smith
John Smith 2020년 2월 16일
댓글: John Smith 2020년 2월 17일
Hi all,
Is there a quick way to reference the previous value of an App Deigner numeric edit field? This is in order to reset the value after an error dialog has been shown. Something like
app.NumericEditField.Value = app.NumericEditField.PreviousValue
would be ideal.
Many thanks.

채택된 답변

Joseph Cheng
Joseph Cheng 2020년 2월 16일
I think thats almost what you'd want do have and store prevvalue during during successful calculation. Previousely in GUIDE and UIcontrol type construction there was a userdata field. I haven't been using appdesigner but it looks to be gone from a cursory inspection. However you can set a private/public property as a place to store the previous value upon successful computation run.
app.NumericEditField_N_PreviousValue= app.NumericEditField.Value
app.NumericEditField.PreviousValue= app.NumericEditField_N_PreviousValue
during an error catch.
  댓글 수: 1
John Smith
John Smith 2020년 2월 17일
Thanks, like you suggested, I stored the previous value in an app property.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Ajay Kumar
Ajay Kumar 2020년 2월 16일
Try to save the Previous value in a temporary variable. For eg:
temp = app.NumericEditField.Value;
if error
app.NumericEditField.Value = temp;
app.NumericEditField.Value = newvalue;





Community Treasure Hunt

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

Start Hunting!

Translated by