-
3 Comments
Anuj Kumar
on 25 Dec 2020
hy,is there a problem with the above mentioned question
Sarker Ashraful Islam
on 4 Jan 2021
l=length(a);
freq=zeros(1,l);
for c=1:l
for r=c:l
if a(c)==a(r)
freq(c)=freq(c)+1;
else
break
end
end
end
M=max(freq);
idx=find(freq==M);
val=a(idx);
震浩 顾
on 25 Jan 2021
function val=longrun(a)
b = zeros(size(a));
old = a(1);
cnt = 0;
for idx = 1:length(a)
if a(idx) == old
cnt = cnt +1;
else
old = a(idx);
cnt = 1;
end
b(idx)=cnt;
end
bmax = max(b);
val = a(b==bmax);
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!