#Day86#100DaysChallenge- Matlab Loops | Frequency of a number in a vector
12
function numcount=num(a,vect)
numcount=0;
for i=1:1:length(vect)
if a==vect(i)
numcount=numcount+1;
end
end
2 2 2 3 5 5
>> 2*2*2*3*5*5
ans =
600
>> numcount=num(2,fact2)
numcount =
3
>> numcount=num(3,fact2)
numcount =
1
>> numcount=num(5,fact2)
numcount =
2
No comments