Matlab App Designer displays an array of numbers when the variable in question is a double

1 view (last 30 days)
I am having trouble displaying a single value in App Designer. I have tried the following code in a .m file and in the command window with no issues, but when implemented into App Designer Matlab outputs an array of numbers:
acc_max = (acceleration(Ifmax1+Acc_start_ind)); % Point of maximum acceleration
F = app.EditField.Value*acc_max; % Edit field provides mass of object to calculate force
APrime = num2str(round(F,1));
app.Label_4.Text = (APrime);
This code performs as expected when "F = app.EditField.Value" as well as "F = acc_max", however when they are multiplied together (as seen above) and then converted to a string I receive multiple numbers well below the expected output. I have used this approach with success in editing other label text, but I cannot seem to work this instance. The received output is given below

Accepted Answer

Steven Lord
Steven Lord on 23 Jun 2022
Instead of using an EditField (whose Value property is the text the user entered in the field according to the documentation) you probably want to use a NumericEditField (whose Value property is the number the user entered in the field, again according to the documentation.)
a = '12345'; % EditField's Value
b = a*2
b = 1×5
98 100 102 104 106
c = 12345; % NumericEditField's Value
d = c*2
d = 24690

More Answers (0)

Community Treasure Hunt

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

Start Hunting!