- NumericEditField.Value: https://www.mathworks.com/help/releases/R2021b/matlab/ref/matlab.ui.control.numericeditfield-properties.html#:~:text=Value%20%E2%80%94%20Value%20in%20edit%20field
- double: https://www.mathworks.com/help/releases/R2021b/symbolic/double.html
May I know why 'value must be a double scalar' come out in app designer?
1 次查看(过去 30 天)
显示 更早的评论
syms x
f_bisection = app.EquationEditField.Value;
f2_bisection = str2sym(f_bisection);
a=app.aEditField.Value;
b=app.bEditField.Value;
iteration=1;
itemax = 70;
if f_bisection(a)*f_bisection(b)>0
disp('Wrong choice')
else
x=(a+b)/2;
while iteration < itemax
if f_bisection(a)*f_bisection(x)<0
b=x;
else
a=x;
end
x=(a+b)/2;
iteration=iteration+1;
end
end
app.RootEditField.Value = x;
0 个评论
回答(1 个)
Nivedita
2023-9-20
Hello Aqilah!
I understand that you are receiving the error “ 'Value' must be a double scalar” in app designer.
I am assuming that this error is thrown for the last line:
app.RootEditField.Value = x;
There are two types of edit fields in app designer: numeric and text. Numeric edit fields only receive double scalar values. Since “x” is a symbolic variable, MATLAB is rejecting the value and throwing the error.
You can convert “x” into a double scalar using the “double” function and assign it to “RootEditField” in the following manner:
app.RootEditField.Value = double(x);
For more information on the “Value” property of “NumericEditFields” in app designer and the “double” function, you can refer to the following documentation links:
I hope this helps!
Regards,
Nivedita.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!