Find a length of string/array without length function
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi All,
Hope everyone is doing great. I have minor question, I am trying to write a simple function to find a length of string/array, of course without using length function of MATLAB.
I am trying to find if there is any condition related to error message index bound, then I can use it in loop. Any other ideas are more than welcome.
Thank you in advance.
댓글 수: 0
채택된 답변
James Tursa
2012년 2월 15일
I have no idea what the point of this question is, but do you mean something like this?
try
k = 1;
while( true )
str(k);
k = k + 1;
end
catch
strlength = k - 1;
end
추가 답변 (2개)
bym
2012년 2월 16일
a variant on your code
str = 'hello world';
c =0;
while ~isempty(str)
c = c+1;
str(1)=[];
end
c
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!