Try this rather straightforward approach using randperm():
inputValues = [1,1,1,2,2,3,2,3,4,4,4,4,4,2,3,4,3,2,1,1] % 20 elements
% Find out how many elements 10% of our input vector is.
elementsToChange = round(0.1 * length(inputValues))
% Randomly choose that many locations to change the value of.
indexesToChange = randperm(length(inputValues), elementsToChange)
outputValues = inputValues; % Initialize
% Get new values for the indexes that we want to change.
newValues = randi(4, 1, length(indexesToChange))
% Assign those values to the locations we selected.
outputValues(indexesToChange) = newValues
Let me know if there is anything you don't follow or understand.