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

조회 수: 10 (최근 30일)
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

채택된 답변

Steven Lord
Steven Lord 2022년 6월 23일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by