-
1 Comment
Swati Sarangi
on 5 Nov 2020
The below code fails for the input:
assert(isequal(ecount([1 1 1 1 NaN NaN 1 1],NaN),2))
Can anyone show me the error?
function ct = ecount(v,e)
s=0;
for i=1:length(v)
if v(i)==e
s=s+1;
elseif v(i)=='NaN'
s=s+1;
i=i+1;
end
ct =s;
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!