Julia - all this code
if PromptMessage == 1
Choice2 = PlayerOption(1);
elseif PromptMessage == 2
Choice2 = PlayerOption(2);
end
seems to be doing is to select a door given the contestant's decision to either remain with his/her current decision (1) or choose the remaining door (2). PlayerOption is simply an array of the two remaining doors (Monty Hall has already opened one door and shown that there is nothing behind it) one of which is the door to the car. The author of the code is creating an array of those two doors with the first one being the door that the user has already selected. So if PromptMessage is 1, then the user will stick with his original choice and so Choice2 is the id for that door (since his/her original choice is the first in the array, the code assigns PlayerOption(1) to Choice2). If the PromptMessage is 2, then the user switches to the other door and it's id is assigned to Choice2. The code then compares this final choice to true winning door id and increments the winning or losing count appropriately.
The code may be a little easier to understand if the variables were named differently. For example,
if playerDecision == 1
% player decides to stick with original door selection
finalDoorId = RemainingDoorIds(1);
elseif PromptMessage == 2
% player decides to choose the other door
finalDoorId = RemainingDoorIds(2);
end
and
%% Determine number of wins and losses
if finalDoorId == winningDoorId
numberOfWins = numberOfWins + 1
else
numberOfLosses = numberOfLosses + 1
end