Question
MATLAB ONLY Function Name: schrodingersCat Inputs: ( struct ) A MxN structure array ( double ) A 1x2 vector of your starting position Outputs: 1.
MATLAB ONLY
Function Name: schrodingersCat
Inputs:
( struct ) A MxN structure array
( double ) A 1x2 vector of your starting position
Outputs:
1. ( char ) A statement describing the cat, its location, and how many steps it took
Background:
In 1935, Erwin Schro?dinger proposed the famous thought experiment in which cat in a box is simultaneously alive and dead. Only once the box is opened can the cat's state of being be determined. Using your MATLAB skills, you have set up the experiment yourself, and you want to figure out if your cat is alive or dead. However, you set up a large array of many boxes, and forgot which one the cat is in. Good thing you have MATLAB to help you out!
Function Description:
You are given a structure array and a set of indices within the structure array at which to start. Each structure in the array contains only one field, called next . The next field of each structure contains either a 1x2 vector of the indices of the next structure to search or a character vector describing the state of the cat. The character vector describing the cat will either be 'alive cat' or 'dead cat' .
To find the cat, first check the structure at the index given by the second input. Next, check the structure at the indices given in the next field of the previous structure you checked. This process should continue until you encounter the cat, whether it is dead or alive. Be sure to keep a count of how many steps you have gone through before you reach the cat. Your output statement should have the following form:
'Thewas found at position ( ,
) after steps.'
Notes:
? The path from the given starting position is guaranteed to reach the cat.
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