Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB D Question 8 Given the following function, answer the questions that follow. 1 functions - playSports (5) 2 viewers (s.Viewers] 3 - Index) =
MATLAB
D Question 8 Given the following function, answer the questions that follow. 1 functions - playSports (5) 2 viewers (s.Viewers] 3 - Index) = sort (viewers); 4 - (index); 5 for =1:length(s) s(1). Rating - index(i) . 5; if instruct(s(1). Equipment) S(1). Expensive true 11 10 if strcmp(s (i). Sport, Football') (1) - [1: 12 end 13 Emfield(s, "Viewers'); 14 end 15 end The following code is run in the command window. >> sports - playSports (sportsStruct) . sportsStruct " 'Track and field' Viewers: 1,500,000 1,000,000 Equipment: 1xl struct Spikes' 'Football' 3,000,000 1x struct # After the above code is run, which fieldnames are in the output structure array? b: After the above code is run, what is the size of the output structure array? Explain an example of a structure array that would cause the function to error. Include the wamber of the line the function would error on. This structure MUST have the fieldnames Sport, Viewers, and Equipment. Please answer the questions in order and indicate the beginning of each of your answers by putting the corresponding letter before your response. HTML Editor BIVA.A.I.EE 3. XEE mBe2 N O TT : 12pt - Paragraph - MacBook Pro CI Q Search or type URL # * w D Question 8 Given the following function, answer the questions that follow. 1 functions - playSports (5) 2 viewers (s.Viewers] 3 - Index) = sort (viewers); 4 - (index); 5 for =1:length(s) s(1). Rating - index(i) . 5; if instruct(s(1). Equipment) S(1). Expensive true 11 10 if strcmp(s (i). Sport, Football') (1) - [1: 12 end 13 Emfield(s, "Viewers'); 14 end 15 end The following code is run in the command window. >> sports - playSports (sportsStruct) . sportsStruct " 'Track and field' Viewers: 1,500,000 1,000,000 Equipment: 1xl struct Spikes' 'Football' 3,000,000 1x struct # After the above code is run, which fieldnames are in the output structure array? b: After the above code is run, what is the size of the output structure array? Explain an example of a structure array that would cause the function to error. Include the wamber of the line the function would error on. This structure MUST have the fieldnames Sport, Viewers, and Equipment. Please answer the questions in order and indicate the beginning of each of your answers by putting the corresponding letter before your response. HTML Editor BIVA.A.I.EE 3. XEE mBe2 N O TT : 12pt - Paragraph - MacBook Pro CI Q Search or type URL # * w 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