Find a length of string/array without length function
3 次查看(过去 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!