countingNumbers

countingNumbers - %order to compare it to the first vector...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function num = countingNumbers(vec1,vec2) %function to count how many times numbers from the second vector occur in %the first vector %usage: num = countingNumbers(vec1,vec2) num=0; for x = vec2 %this takes the first element of vec2 and runs it through the for loop in
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %order to compare it to the first vector num = sum(x==vec1) %this will add the trues (which will just be 1s) from the comparison %between the element in vec2 and the entire vec1 end end...
View Full Document

Ask a homework question - tutors are online