Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Grid ( 2 , 2 ) Righ Thus, the maximum number of collected carrot is 9 and the best path is: Grid ( 1 ,
Grid
Righ
Thus, the maximum number of collected carrot is and the best path is:
Grid Grid Grid
MATLAB Coding
For the problem given in Section write a MATLAB program that returns the best path taken by the rabbit from starting point to the end point and the maximum number of carrots collected by the rabbit.
Your MATLAB program should at least contain one function file and one script calling the function file to produce the result on the Command Window. The script should receive the information of the grid and then call the fProblem Description
jure illustrates a grid of by where each cell square contains number of rrots. For example, in the Start cell there is one carrot and in the End cell there e carrots. The rabbit shown below aims to start a journey from Start cell toward d cell and to collect the maximum number of carrots. The rabbit can only move Right direction or Top direction as shown by the arrows below.
hus, the ultimate objective of this problem is to find the best path in the grid that sults in the collection of maximum number of carrots.
Right
Figure Graphical representation of the problem of finding the best path results in the maximum number of carrots.
Hints for Solving the Problem
There are different approaches for solving this problem. One approach is to consider the following rules for finding the best path and finally maximum number of carrots:
Grid
Righ
Thus, the maximum number of collected carrot is and the best path is:
Grid Grid Grid
MATLAB Coding
For the problem given in Section write a MATLAB program that returns the best path taken by the rabbit from starting point to the end point and the maximum number of carrots collected by the rabbit.
Your MATLAB program should at least contain one function file and one script calling the function file to produce the result on the Command Window. The script should receive the information of the grid and then call the function file to solve it The output on the Command window should be like this:
The best path is: Grid Griddots,Grid
The maximum number of carrots collected is:
Important Note: Your MATLAB program should be comprehensive and can be applied on any by grid. It means that if you feed a new grid with different number of carrots in each cell comparing to the above grid to your MATLAB program, it should be able to solve it You should show this verification as well.
Problem Description
Figure illustrates a grid of by where each cell square contains number of carrots. For example, in the Start cell there is one carrot and in the End cell there are carrots. The rabbit shown below aims to start a journey from Start cell toward End cell and to collect the maximum number of carrots. The rabbit can only move in Right direction or Top direction as shown by the arrows below.
Thus, the ultimate objective of this problem is to find the best path in the grid that results in the collection of maximum number of carrots.
Figure Graphical representation of the problem of finding the best path results in the maximum number of carrots.
Hints for Solving the Problem
There are different approaches for solving this problem. One approach is to consider the following rules for finding the best path and finally maximum number of carrots:
In the Start cell, the maximum number of carrots is the number of carrots indicated.
The maximum number of carrots for other cells is equal to summation of number carrots on that cell with maximum number of carrots on the adjacent cells.
For example, for the following by grid, we have:
Right
Thus, the maximum number of collected carrot is and the best path is:
Grid Grid Grid
MATLAB Coding
For the problem given in Section write a MATLAB program that returns the best path taken by the rabbit from starting point to the end point and the maximum number of carrots collected by the rabbit.
Your MATLAB program should at least contain one function file and one script calling the function file to produce the result on the Command Window. The script should receive the information of the grid and then call the function file to solve it The output on the Command window should be like this:
The best path is: Grid Grid dots, Grid
The maximum number of carrots collected is:
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