Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab help: Function Name costumeContest Inputs 1. ( struct) 1xN structure array with the description of a persons costume 2. ( char) The banned field

Matlab help:

Function Name costumeContest

Inputs

1. ( struct) 1xN structure array with the description of a persons costume

2. ( char) The banned field

Outputs

1. (char) A phrase stating who the winner is and who the runner up is

2. ( struct) 1x(N-1) structure array of the losers of the contest

Background

Its officially sp00ky season. Youve been planning your costume all year long and now its

time to show this whole town what youve got. But alas! The judges say itll take all night to finish

the scoring by hand and you were planning to go get your trick or treat on right after the contest.

So, to help the judges, you create a function in MATLAB to speed up the process.

Function Description

Write a function that takes in a 1xN structure array of contestants and finds the winner

based on these criteria. Each structure will contain a Contestants field with the name of the

person, an Originality field with a numerical score, and a series of fields that represent

attributes of their costumes.The values of those fields will be 'Yes' or 'No'.

1. Delete the contestants with a value of 'Yes' for the banned field, then delete the field

from the structure array.

2. Find if the Cardboard and Makeup fields exists. Then find the contestants that use

Cardboard or Makeup . Add three points to their originality if they have a 'Yes' as the

value for either of those fields. If they have both Cardboard and Makeup add 8 points to

their originality score.

3. Sort the structure array by the Originality score in descending order.

4. Remove the Originality field to keep the scores a secret.

5. Find the first place winner (the costume with the best originality score) and the runner up

and output the results like so:

' is the winner of the costume contest! and is the first

loser, I mean second place winner of the costume contest!'

6. Output the losers in a structure array. This is everyone except first place.

Homework 10 - Structures

Example

>>banned = 'Jewelry'

>>costumes =

Contestants: Buzz

Tights: Yes

Cardboard: Yes

Jewelry: No

Originality: 10

Contestants: Danny

Tights: No

Cardboard: Yes

Jewelry: No

Originality: 5

Contestants: Patricia

Tights: Yes

Cardboard: Yes

Jewelry: Yes

Originality: 7

>> [results, losers] = costumeContest (costumes, banned)

>>results 'Buzz is the winner of the costume contest! And Danny is

the first loser, I mean second place winner of the costume

contest!'

>>losers

Contestants: Danny

Cardboard: Yes

Tights: No

Notes

The disqualifying feature will always be a field name.

Hints

Remember that you can mask cell arrays.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions