APP DESIGNER EDIT FIELD ISSUE---HELP REQUESTED

조회 수: 4 (최근 30일)
Alex
Alex 2025년 3월 21일
댓글: Image Analyst 2025년 3월 21일
Hi,
Running 2024b:
I'm seeing a weird issue with Edit Field (numeric) values in App Designer. When I enter numbers, then try to confirm what the values are with the Test button, I get character symbols, rather than numbers in the command window. I can avoid this with Edit Field (Text)---but I can't for the life of me figure out why the numeric field entries aren't working. Similarly, I tried adding a spinner and displaying its value on a UI, but it is also corrupted. The numeric field shows the same odd behavior with a UI display as well.
I've attached the app.
  댓글 수: 1
Steven Lord
Steven Lord 2025년 3월 21일
Can you show the code in the callback for your Test button?

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

채택된 답변

Walter Roberson
Walter Roberson 2025년 3월 21일
Your code has
disp(['EditField1.Value =' , app.EditField.Value]);
This does a horzcat() operation between a character vector and a numeric value. The [] operation between a character vector and a numeric value is defined as [CHARACTERVECTOR char(uint16(floor(NUMERICVALUE)))] . Which is to say that the numeric values are treated as unicode character positions and the corresponding characters are output.
[] between a character vector and a numeric value does not format the numeric value as printable characters.
You need one of
disp("EditField1.Value =" + app.EditField.Value);
or
disp(compose("EditField1.Value = %g", app.EditField.Value));
or
fprintf('EditField1.Value = %g\n', app.EditField.Value)
or
fprintf('EditField1.Value = %.999g\n', app.EditField.Value)
The first version will output the Value with no more than 4 numeric places after the decimal. The %g versions will output the Value with no more than 5 numeric places after the decimal. The version with %.999g will output the value with full and complete precision of value stored, such as 0.1000000000000000055511151231257827021181583404541015625 for 0.1
  댓글 수: 2
Alex
Alex 2025년 3월 21일
Thanks!
Image Analyst
Image Analyst 2025년 3월 21일
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
For full details on how to earn reputation points see: https://www.mathworks.com/matlabcentral/answers/help?s_tid=al_priv#reputation

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by