Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function name: warriors Need the MATLAB code for this one! Much appreciated! Function Name: warriors Inputs 1. (struct) An 1xN structure array 2. (char) A

image text in transcribed

image text in transcribed

Function name: warriors

Need the MATLAB code for this one! Much appreciated!

Function Name: warriors Inputs 1. (struct) An 1xN structure array 2. (char) A field name Outputs 1. (struct) An 1xM updated structure array 2. (char) A descriptive statement about the clan battle Background While reading everyone's favorite childhood book series about clans of feral cats Warriors, you realize that the plot is quite difficult to keep up with at times. Rather than simply following the exciting adventures of the protagonist, Firepaw of the ThunderClan, like a casual reader, you decide to go the extra step. Since you are such a dedicated fan of this incredible series, you will write a MATLAB function to track the battles of the clans throughout the saga Function Description Write a function that takes in an 1XN structure array and a field name of a statistic that is the most important in a particular battle. Each structure in the array represents a different clan of cats. Based on the values of the field from the given field name (second input) which are guaranteed to be of type double, you will determine which clans battle and who will win. The clan with the highest value in the given field will win in a warrior battle against the clan with the lowest value in the given field. Any intermediary clans will not be affected by the battle. Make the following updates to the structure array based on this battle 1. The winning clan's structure's value in the field given by the second input should be doubled 2. The winning clan's structure's value of the Territories field, represented by a cell array of strings, should be updated to include the values of the Territories field in the losing clan's structure The losing clan's value in the field given by the second input should be set to zero The losing clan's value for the Territories field should become an empty cell array 3. 4. 5. Sort the entire array in descending order based on the values in the field given by the second input. Do this using the 'descend input to sort. In addition to updating the structure array, the function should also output a descriptive statement in the following format Following the warrior code, fearless leader to victory against

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

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

b. Where did they come from?

Answered: 1 week ago

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago