Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#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

 

Sample Input and Output

 fact2 =


     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

 

Click here for Video Description.


No comments

Popular Posts

Followers