For my college class I have this problem Assign numMatches with the number of elements in userValues that equal matchValue. Ex: If matchValue = 2 and userVals = [2, 2, 1, 2], then numMatches = 3.
My code is
function numMatches = FindValues(userValues, matchValue) arraySize = 4; % Number of elements in userValues array
numMatches = 0; % Number of elements that equal desired match value
for i = 1:arraySize if (userValues ~= matchValue) numMatches = arraySize - i end end end
I also tried
If (userValues == matchValue)
but it did not work I tried with a input of FindValues([2, 2, 1, 2], 2) and it didn't work.
any recommendations
Best Answer