-
2 Comments
Haoyu Dai
on 30 Apr 2020
function y = lengthOnes(x)
cnt=0;
a=[];
L=strlength(x);
for i=1:L
if x(i)=='1'
cnt=cnt+1;
else
cnt=0;
end
a(i)=cnt;
end
[y,index]=max(a);
end
Syed Shahed
on 3 May 2020
Excellent work man :)
Suggested Problems
-
Create a cell array out of a struct
2201 Solvers
-
Omit columns averages from a matrix
599 Solvers
-
Count consecutive 0's in between values of 1
464 Solvers
-
812 Solvers
-
1076 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!