Question
Inputs: 1. (char) A 1x(6*N) vector of Olympic events 2. (logical) A 1xN vector of whether or not the athlete competes in the event Outputs:
Inputs:
1. (char) A 1x(6*N) vector of Olympic events 2. (logical) A 1xN vector of whether or not the athlete competes in the event
Outputs:
-
(char) A 1xP vector of the Olympic events that the athlete doesn't compete in
-
(double) A 1xM vector of the original positions of the events the athlete competes in
Background:
You just started working for the Olympic Committee and on your first day the system mixed up what events different athletes compete in. As MATLAB is your specialty, you've been tasked with determining the correct events for a certain athlete! Fix the Summer Olympics!
Function Description:
Given a list of the first 5 letters of different Olympic events and a logical vector of whether the athlete competes in that event, output the events that should not be included in the athlete's event list. You should also output a vector of the positions of the events that belong in ascending order.
Example:
events = 'TRACK SWIMM DIVIN FENCI ' belong = [true true] [wrong, positions] = eventList(events, belong) wrong 'CYCLI BOXIN '
positions [1 3 5 6]
Notes:
-
Event names will always be five capital letters followed by a space, both in the input and output.
-
You will not be given a test case with no falses in the logical input vector.
Hints:
-
Think about how you can create a mask the same size as the string input.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started