Eris - if you want to keep rolling until you have a Yatzhee, then you probably want to use a while loop.
% set the roll count to one as this will be the initial roll
rollCount = 1;
% may want to add another condition to only allow a maximum number of rolls
% (like the game)
% so we continue looping until the roll_again array is empty
while ~isempty(roll_again)
rerollResult = ceil(randi([1,6],1,size(roll_again,2)))
rollCount = rollCount + 1;
% if not all of the re-rolls match the common outcome, then remove the
% ones that do and start again
if ~all(rerollResult == commonOutcome)
roll_again(rerollResult == commonOutcome) = [];
else
fprintf('It took %d rolls to get a Yatzhee!\n', rollCount);
break;
end
end
The above can be made more efficient. You may also want to remove some of the for loop from your code because I don't think they are all necessary (unless that is required as part of the assignment).