matlab function name battlezone inputs 1 char filename of the battlefie ld 2 double 5151576
Function Name: battleZone Inputs 1. (char) Filename of the battlefie ld 2. (double) Number of days of fighting File Outputs: 1. A txt file of the updated battlefie ld Background: As the high-ranking General you are, it is your job to plan out your battle strategies carefully to ensure the success of your troops. You are aware that battles are complex and disorde red, but you can still identify a few trends that happen in terms of the movement of your troops on the battlefield. With little time on your hands, you call upon your trusted ally MATLAB to analyze the field and determine the course of the battle over the next few days. Function Description You are given a text file containing a map of a battlefield, with the characters and '1 representing tiles of open ground, encampments, and soldiers respectively. Every day some changes occur to the battlefield as the fight progresses, based on the following criteria: 1. A tile of open ground will become a soldier if it is adjacent to at least one en campment Otherwise, nothing happens 2. A soldier tile will become an encampme nt if it is adjacent to at least two soldiers Otherwise, nothing hap pens. 3. An encampment become an open tile if it is adjacent to fewer than two soldiers Otherwise, nothing happens A An element is considered adjacent if it is directly above, below, to the right of, or to the left of the element in consideration (diagonals are NOT considered adjace nt). You must extract the map from the text file, update the map to show its status after N days and print out the new map to a new file with the same name as the original, but with _updated. txt' appended. Example: N 2 map A i 1 iA i iA i '.A i. .i. .i A Initial Field Day 1 Day 2 Notes: Do not ignore edge and comer cases, these tiles will have fewer adjacent tiles but stll follow the same rules. The whole map must be updated all at once.