Simulate a living system of predators-preys

Assignment Help Simulation in MATLAB
Reference no: EM133284213

Engineering Analysis and Numerical Methods

Introduction

The main goal of this assignment is to simulate a living system of predators-preys and its evolution according to a simplified set of rules of death and survival. The living system is represented by the following elements:

• A square grid of cells (represented in a MATLAB environment as a 2D array).

• A representations in each square for the prey, predator, and bare ground (represented in a MATLAB environment with a numerical encoding).

• A set of rules that each square will obey designed to imitate the behaviour of the prey, predator, or bare ground (represented in a MATLAB environment with a set of conditional statements).

Problem description

The living system is represented as a 2D array of any size, predators, prey and bare ground have the following encoding
• Predator → 2
• Prey → 1
• Bare Ground → 0

This is for example a 6x6 living system with 8 preys and 2 predators

2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

Each cell has 8 surrounding cells. For example the surrounding cells of the cell at position (2,2), that represents a prey, are the one highlighted in bold

2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

Since the cells on the edge of the grid don't have 8 surrounding cells, you should consider the grid as if horizontal and vertical edges are wrapped around, so that each cell has 8 surrounding cells. Please refer to the examples below to understand the concept

2 0 0 1 0 0
2 0 0 1 0 0
2 0 0 1 0 0
0 1 1 0 0 0
0 1 1 0 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 2 1 0 0
0 0 2 1 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 0 1 1 0 0
surrounding of cell (1,1) surrounding of cell (6,4) surrounding of cell (5,1)

Each cell survives (the value stays the same) or dies (the cell becomes bare ground) in the next generation (the generations are simulated with a for loop) depending on the state of the surrounding cells (the 8 cells described above) and the following set of rules:
• a prey cell dies for overpopulation if more than 3 of the surrounding cells are preys
• a prey cell dies for underpopulation if less than 2 of the surrounding cells are preys a bare ground cell with at least three prey cells in its surrounding becomes a prey in the next generation to simulate the process of re-population;
a prey cell dies if there is at least one predator in the surrounding cells and no other prey that can help to defend itself.
• a predator cell dies for starvation if there is no prey cells in its surrounding.

This is an example of 3 generations

2305_generations.jpg

You have to write a MATLB function that takes as input
• a 2D array that represents the initial scenario
• the number of generations and returns as output the evolved grid and the number of preys and predators alive at the end of the evolution process. The function, will implement the evolution of the system given the initial state and the number of generations.

At the beginning of your function you have to insert a check on the correctness of your inputs, namely
• the input 2D array needs to be square
• the input 2D array needs to be initialised with values 0-1-2, no other value is allowed
• the input number of generations needs to be positive
If any of the checks fails the function returns an error message to screen and exits by return- ing as output a scenario without preys or predators (zeros 2-D array) with number of preys and predators equal to zero.

Validation

This is an example that you can use to validate if your function works, where M is the input grid, 15 and 30 the number of generations used, G the evolved system, n the final number of preys and m the final number of predators:
>> M

M=
2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

>> [G,n,m] =preypredator(M, 15 ) G=

2 0 0 0 0 1
0 0 0 1 1 1
0 1 1 0 0 1
0 0 1 0 1 0
0 0 2 1 0 0
0 0 0 0 0 0
n= 10
m= 2

>> [G,n,m] =preypredator(M, 30 )

G=

0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0

n = 3 m= 0

Reference no: EM133284213

Questions Cloud

What does arendt mean by immortality : What does Arendt mean by "immortality"? How does it differ from "eternity"? How do they each relate to politics?
Differentiate between line and staff functions : Differentiate between Line and Staff functions in an organization and discuss the possible conflicts that arise in the interaction bes officers or personnel
Important sources of political socialization : What do you think the most important sources of political socialization are in shaping our political value system?
Why do you think democracy is so fragile : Why do you think democracy is so fragile and prone to reactionary conservative and violent forces, as in the former Yugoslavia
Simulate a living system of predators-preys : ME108 Engineering Analysis and Numerical Methods - University of Strathclyde write a MATLB function the number of generations and returns as output
Explain history of the reconstruction finance corp : In 1932, Congress established the RFC with a limited mandate to provide emergency loans to banks, Explain History of the Reconstruction Finance Corp
Explain nature of queen power in buganda : Explain the nature of the queen's power in Buganda and explain the reasons behind the loss of women's political power in nineteenth-century East Africa.
Discuss the stock market crash : The United States entered World War II in 1941, the same year as the Great Depression, which lasted from 1929 to 1941. Discuss The Stock Market Crash
Ethic of ultimate ends and ethic of responsibility : Weber distinguishes between an "ethic of ultimate ends" and an "ethic of responsibility." What does he mean by each?

Reviews

Write a Review

Simulation in MATLAB Questions & Answers

  Simulate using beam propagation method

Simulate using BPM (Beam propagation method) the following wave guid?

  Use the matlab program to simulate an open loop system

For this laboratory you will use the MATLAB program to simulate an open loop system. You are to determine the system response to a step and sinusoidal input. Each student will be assigned a specific system Your system transfer function is

  What comfort zones do you find for these parameters

What "comfort zones" do you find for these parameters from the viewpoint of simulating the system? Are these "comfort zones" the same

  Find the roots for polynomials shown using matlab

INLAB Report (1): Find the roots for polynomials shown above using MATLAB. Can you guess a function which finds "roots" for polynomials in MATLAB? Use help in MATLAB to find the syntax for function

  Simulate the standardised sum of independent

Simulate the standardised sum of independent and identically distributed variates - Fit a linear regression model as in Q5, and plot your estimates for β0 and β1 as N increases, together with a line indicating their true values. Supply your code.

  Perform the matched filtering on the return signal

Understand and simulate the radar transmitted and return signals with added noise, delay and Doppler shifts to the return signal

  What is the total variability in the dataset

This problem is aimed at helping you understand the PGA method using an idealized dataset Since you know the data you are generating. it should help you understand the capability of the method. Perform a principal component analysis on the dataset ..

  Prepare report regarding state of prototype production line

Prepare a technical report regarding the state of the prototype production line in comparison to the current production line.

  Build a hopfield network

CPNS 33200 Computational Neuroscience - Neural Networks Lab I: Unsupervised Learning - Build a Hopfield network to store the good and bad prototypes

  Build a matlab based graphical user interface

Build a Matlab based graphical user interface (GUI) that operates in conjunction with a base Matlab/ Simulink simulation program. Any base simulation is considered acceptable.

  Produce a simulation of the mechanism motion

Write a code to produce a simulation of the mechanism motion using the equation written in red in the file.

  AE03 Automotive Control and Simulation Assignment

AE03 Automotive Control and Simulation Assignment Help and Solution, Cranfield University - Assessment Writing Service

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd