Question

In: Advanced Math

this is my Matlab code for lemur and plant population simulation. But i didn't get the...

this is my Matlab code for lemur and plant population simulation. But i didn't get the right graph.

R(1,1)=35; % Initial pop of males
R(2,1)=35; % Initial pop of females
P(3,1)=200000; % Iniitial pop of plants
r(1)=1.01; % Growth rate of male pop
r(2)=1.01; % Growth rate of female pop
r(3)=1.10; % Growth rate of plants
K(1)=800; % Carrying capacity for male pop
K(2)=600; % carrying capacity for female pop
K(3)=7500000; % carrying capacity for plants
  
E=65; % Plants per animal
A=150000; % Animal 'Plant needs'
NW=200; % Weeks for simulation
  
for m=2:NW
  
P(3,m)=(r(3)*P(3,m-1)*((K(3)-P(3,m-1))/K(3))) -(E*R(m));

R(m-1)=R(1,m-1)+ R(2,m-1);
  
R(1,m)=(r(1)*R(1,m-1)*(K(1)-R(1,m-1))*P(3,m-1))/(K(1)*A);
R(2,m)=(r(2)*R(2,m-1)*(K(2)-R(2,m-1))*P(3,m-1))/(K(2)*A);

end
  
subplot(1,2,1)
plot(1:NW,R(1,1:NW),1:NW,R(2,1:NW))
xlabel('Month')
ylabel('population')
legend('male','female')
  
subplot(1,2,2)
plot(1:NW,P(3,1:NW))
xlabel('Month')
ylabel('Plant population')
  
  

Solutions

Expert Solution

i guessed there are two problems with this code.

(i) There is direct assignment to the third row of P matrix. The first two rows of P matrix are zeros. So there is no need of the first two rows. Instead of P(3,m) you can use R(3,m).

(ii) How you are updating and using R(m) and R(m-1) ?? ... Doing R(m) in MATLAB considers R(m,1) by default. If you mean this, then it is right... otherwise you've to look into this.

However, I've corrected the first issue and the code is listed below :

---------------

R(1,1)=35; % Initial pop of males

R(2,1)=35; % Initial pop of females

R(3,1)=200000; % Initial pop of plants

r(1)=1.01; % Growth rate of male pop

r(2)=1.01; % Growth rate of female pop

r(3)=1.10; % Growth rate of plants

K(1)=800; % Carrying capacity for male pop

K(2)=600; % carrying capacity for female pop

K(3)=7500000; % carrying capacity for plants

  

E=65; % Plants per animal

A=150000; % Animal 'Plant needs'

NW=200; % Weeks for simulation

  

for m=2:NW

  

R(3,m)=(r(3)*R(3,m-1)*((K(3)-R(3,m-1))/K(3))) -(E*R(m));

R(m-1)=R(1,m-1)+ R(2,m-1);

  

R(1,m)=(r(1)*R(1,m-1)*(K(1)-R(1,m-1))*R(3,m-1))/(K(1)*A);

R(2,m)=(r(2)*R(2,m-1)*(K(2)-R(2,m-1))*R(3,m-1))/(K(2)*A);

end

  

subplot(1,2,1)

plot(1:NW,R(1,1:NW),1:NW,R(2,1:NW))

xlabel('Month')

ylabel('population')

legend('male','female')

  

subplot(1,2,2)

plot(1:NW,R(3,1:NW))

xlabel('Month')

ylabel('Plant population')

------------------------------

I hope you will find it useful.

Thank You!


Related Solutions

My projects is to write or find Matlab code for 4FSK(frequency shift keying) with simulation pictures...
My projects is to write or find Matlab code for 4FSK(frequency shift keying) with simulation pictures and create the signal after that add noise to it and finally demodulate it .. Please help me to do this project.
I need a matlab code for my presentation. Code should include Single Sideband Amplitude Modulation and...
I need a matlab code for my presentation. Code should include Single Sideband Amplitude Modulation and Demodulation. It should figure 3 things: -time domain of given message signal in Amplitude Modulation and Single Sideband Amplitude Modulation -frequency domain of given signal in Amplitude Modulation and Single Sideband Amplitude Modulation -And it should demodulate and show message signal.
VHDL Code will not run simulation. What is the problem with my code?? --VHDL Code library...
VHDL Code will not run simulation. What is the problem with my code?? --VHDL Code library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.NUMERIC_STD.ALL; entity DataMemory16Bits is Port ( Address_DM : in STD_LOGIC_VECTOR(15 downto 0); Data_In_DM : in STD_LOGIC_VECTOR(15 downto 0); Clock : in STD_LOGIC; We_DM : in STD_LOGIC; Re_DM : in STD_LOGIC; Data_Out_DM : out STD_LOGIC_VECTOR(15 downto 0)); end DataMemory16Bits; architecture Behavioral of DataMemory16Bits is Type DataMemory16Bits is array(0 to 31) of STD_LOGIC_VECTOR(15 downto 0); signal memory: DataMemory16Bits; begin process...
I cannot get this code to run on my python compiler. It gives me an expected...
I cannot get this code to run on my python compiler. It gives me an expected an indent block message. I do not know what is going on. #ask why this is now happenning. (Create employee description) class employee: def__init__(self, name, employee_id, department, title): self.name = name self.employee_id = employee_id self.department = department self.title = title def __str__(self): return '{} , id={}, is in {} and is a {}.'.format(self.name, self.employee_id, self.department, self.title)    def main(): # Create employee list emp1...
this is my matlab code for class, my professor commented "why is the eps an input...
this is my matlab code for class, my professor commented "why is the eps an input when it is set inside the function and not specified as a variable? how do i fix? function[] = () %Declare Global Variables global KS; global KC; KC = 0; KS = 0; End = 0; while (End == 0) choice = questdlg('Choose a function', ... 'Fuction Menu', ... 'A','B','B'); switch choice; case 'A' Program = 'Start'; while strcmp(Program,'Start'); Choice = menu('Enter the Trigonometric...
I didn't know , how to write this code // This file is part of www.nand2tetris.org...
I didn't know , how to write this code // This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/04/Fill.asm // Runs an infinite loop that listens to the keyboard input. // When a key is pressed (any key), the program blackens the screen, // i.e. writes "black" in every pixel; // the screen should remain fully black as long as the key is...
It shows me that 1 error exists in this code but I didn't know how to...
It shows me that 1 error exists in this code but I didn't know how to fix this error so if you can help I will appreciate it. Language C++. Code: #include <iostream> #include <string> #include <iterator> #include <fstream> #include <sstream> #include <cstdlib> #include <set> using namespace std; class Book { private: string BookId; string BookISBN; string Publisher; int PublisherYear; double Price; int Quantity; string Author; public: string SetBookId(); string SetBookISBN(); string SetPublisher(); int SetPublisherYear(); double SetPrice(); int SetQuantity(); string...
I'm new in MATLAB and I have to write a code in MATLAB which converts a...
I'm new in MATLAB and I have to write a code in MATLAB which converts a number from one base to another without using base2base, etc
Python I want to name my hero and my alien in my code how do I...
Python I want to name my hero and my alien in my code how do I do that: Keep in mind I don't want to change my code except to give the hero and alien a name import random class Hero:     def __init__(self,ammo,health):         self.ammo=ammo         self.health=health     def blast(self):         print("The Hero blasts an Alien!")         if self.ammo>0:             self.ammo-=1             return True         else:             print("Oh no! Hero is out of ammo.")             return False     def...
The following code must be written using matlab How to get the elements that are different...
The following code must be written using matlab How to get the elements that are different in two set without using the setdiff function in matlbab?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT