This challenge activity uses a 3rd parly app Though your act
This challenge activity uses a 3rd parly app. Though your activity may be recorded, a refresh may be required to update the banner to the left. Create a logic array qualifyinglndex with true for any location where the runner is male with a running time less than 8.2. Row array runnerGenders indicate if a runner if male (M) or female (F). Row array runnerTimes indicates the corresponding runner\'s time. Code to call your function when you click Run Check if FindQualifying([\'M\', \'F\', \'M\', \'F\'], [8.5, 9, 7.7, 7.9, 7.2]) returns [0, 0, 1, 1, 0]
Solution
% function to return binary array
function qualifyingIndex = findQualifying(runnerGenders, runnerTimes)
% initializing array to zeros
qualifyingIndex = zeros(size(runnerGenders));
for x = 1:length(runnerGenders)
% checking whether gender is male and time is less than 8.2
if(runnerGenders(x) == \'M\' && runnerTimes(x) < 8.2)
qualifyingIndex(x) = 1;
end
end
end
% calling function and storing returned values in result
result = findQualifying([\'M\',\'F\',\'M\',\'M\',\'F\'],[8.5, 9, 7.7, 7.9, 7.2]);
disp(result);
---------------------------------------------------------------------
SAMPLE OUTPUT
0 0 1 1 0
