This challenge activity uses a 3rd party app Though your act
This challenge activity uses a 3rd party app. Though your activity may be recorded, a refresh may be required to update the banner to the left. Assign num Matches with the number of elements in user Values that equal match Value. Ex: If match Value = 2 and userVals = [2, 2, 1, 2]. then num Matches = 3.function num Matches = Find Values (user Values, match Value) % user Values: User defined array of values %match Value: Desired match value array Size =4; % Number of elements in user Values array num Matches =theta; % Number of elements that equal desired match value % Write a for loop that assigns num Matches with the number of % elements in user Values that equal match Value.
Solution
% matlab code
function numMatches = FindValues(userValues, matchValue)
arraySize = 4;
numMatches = 0;
% itearte over userValues
for i = 1:arraySize
% find match
if userValues(i) == matchValue
numMatches = numMatches + 1;
end
end
end
numMatches = FindValues([2,2,1,2],2);
disp(numMatches);
%output: 3
