필터 지우기
필터 지우기

How does one count the characters in an array?

조회 수: 5 (최근 30일)
Jay
Jay 2016년 4월 11일
댓글: Jay 2016년 4월 17일
How do I obtain an arrays character count?
Eg. Value = 1111
I want the character count output to be 4
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 4월 11일
Is that
Value = 1111
or is it
Value = '1111'
If it is numeric, then how do you want to process negative numbers, and how do you want to process numbers with fractional part, and how do you want to process numbers that would typically be expressed in scientific notation?

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 11일
value='1111'
out=numel(value)
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 4월 12일
(It turns out this is not what Justin wanted)

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

추가 답변 (2개)

Andrei Bobrov
Andrei Bobrov 2016년 4월 11일
편집: Andrei Bobrov 2016년 4월 11일
If your Value is numeric type, then:
out = floor(log10(Value)+1);
if Value is char type then:
out = numel(Value - '0');

Jay
Jay 2016년 4월 11일
편집: Jay 2016년 4월 11일
That does not work.
The characters are not explicitly defined as elements in an array, but rather string values in a handle.
elCount = str2num('Value') = []
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 4월 13일
Edit boxes do not have a Value. Edit boxes have a String.
S = get(handles.edit1, 'String');
length(S)
Jay
Jay 2016년 4월 17일
Thankyou Walter.

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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by