When the variables of the equation are zero, the equation cannot be solved and results in reading 'Value' must be a double scalar within the range of 'Limits'.

조회 수: 4 (최근 30일)
app.RADARAoEditField_2.Value = ((app.TOTALOSTIMEEditField.Value - app.TOTALDOWNTIMEEditField_4.Value)/app.TOTALOSTIMEEditField.Value)*100;
app.TOTALOSTIMEEditField.Value and app.TOTALDOWNTIMEEditField_4.Value, both values reads, 1x1 double = 0
But zero is causing an error in this function. Please advise.

답변 (1개)

Steven Lord
Steven Lord 2021년 12월 2일
I'm guessing you have a NumericEditField in your app. What are the values for the properties Value and Limits of your edit field?
fig = uifigure;
ef = uieditfield(fig, 'numeric');
ef.Limits = [0 1];
If you tried to set the Value property to a value that is outside your limits then you will receive an error. If I take that sample code above and add this line:
ef.Value = 2; % greater than the upper Limits
I receive the error "'Value' must be a double scalar within the range of 'Limits'." 2 is greater than 0, but it is not less than 1.
  댓글 수: 2
shnrndll
shnrndll 2021년 12월 3일
Thank you Steve. Within my app designer the limit for the variable, app.RADARAoEditField_2.Value is -Inf, Inf
Therefore all values should work. Please advise if you have other ideas. This issue only happens for the value of 0 but (+/-)infiniti should cover all ranges.

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

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by