Question: Write a MATLAB function M-file named RPSLK to play a round of Rock-Paper-Scissors-Lizard-Spock. The input arguments to the function will be two characters, P1 &

Write a MATLAB function M-file named RPSLK to play a round of Rock-Paper-Scissors-Lizard-Spock. The input arguments to the function will be two characters, P1 & P2, one for each player in the game. The character values can be R (for rock), P (for paper), S (for scissors), L (for lizard) and K (for Spock). The output argument, outcome, is for the result The function should return 1 if player 1 wins, 2 if player 2 wins, and zero if it is a tie. This game is traditionally played with hand gestures, which we have replaced with the five characters. The winner is determined as shown in the graphic. For example, lizard (mouth-shaped) beats Spock (live long & prosper) and paper (flat hand), as indicated by the green arrows. The function should return a red error message for the following conditions. Any input is nonscalar Any input is not one of the 5 specified characters
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
