필터 지우기
필터 지우기

How to count of numbers in matlab GUI program?

조회 수: 2 (최근 30일)
95
95 2020년 4월 13일
답변: Rajani Mishra 2020년 4월 16일
the first Edit Field “Input Numbers” is a ‘Text’ Edit Field, and the other two below are ‘Numeric’ Edit Fields.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 4월 14일
Is this to be done through optical character recognition? Is it something that has to be passed the handle of a figure and it has to figure out the number of visible numbers?
... You missed the '3' in the title "Q3" by the way.

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

답변 (1개)

Rajani Mishra
Rajani Mishra 2020년 4월 16일
You can try following steps to find the count of numbers in the Edit field:
  • Retrieve the string entered from the Edit Field
x = get(handles.editField,'String');
if isempty(x)
fprintf('Error: Enter Text first\n');
else
% Code for spliting the string on delimiters and returning the length of the string after
% (explained below).
end
  • Split the string on the delimiters, in your case - ',' and '<space>'
x2 = strsplit(x,{'',','});
  • Remaining string will only have numbers hence length of this string array will be the count of numbers (Given that in the "Input Numbers" text field user only inputs numbers)
Hope this helps!

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by