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...
I can't get the number of days to print. Here is my code: public static void...
I can't get the number of days to print. Here is my code: public static void main(String[] args) { // Prompt the user to enter year Scanner scanner = new Scanner(System.in); // Prompt the user to enter year System.out.print("Enter full year (e.g., 2016): "); int year = scanner.nextInt(); for(int i = 1; i <= 12; i++) printMonth(year, i); } /** Print the calendar for a month in a year */ static void printMonth(int year, int month) { // Print the...
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...
In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT