MATLAB (Part-B) Prome
MATLAB (Part-B) Prome
Salsabun Bahahuti
ID: 22203008
ID-22203010
Question(1)
Suppose we have a pond that will support 2000 fish, and the initial population is 80
fish.Find the number of fish in the lake at any time t.(Use the Logistic Model)
Logistic Population Model:
The logistic growth model describes population growth that starts exponentially but slows as the population
reaches its carrying capacity. This model is more realistic than simple exponential growth because it accounts for
limited resources. The equation is:
Where:
The population grows quickly when it is small but slows down as it approaches K, modeling real-world population
dynamics.
Problem Statement
A pond has a carrying capacity of 2000 fish, with an initial population of 80 fish. The population growth follows the
logistic model:
dP/dt = rk (1 - P/K)
where:
Solution Methodology
1. Define the logistic growth equation in MATLAB using symbolic math.
Code
clc
clear all
1|Page
Salsabun Bahahuti
ID-22203010
syms k
syms K
syms P(t)
solution=dsolve (diff(P)-k*(1-P/K)*P==0,P(0)==80)
solution =
Result
❖ The fish population follows a logistic growth pattern, starting from 80 and gradually increasing.
❖ The growth rate is initially high but slows down as the population approaches the carrying capacity (2000 fish).
❖ The pond's maximum sustainable fish population is 2000, preventing unlimited growth.
❖ The MATLAB plot will show an S-shaped curve, characteristic of logistic growth.
Conclusion
2|Page
Salsabun Bahahuti
ID-22203010
This problem demonstrates the application of logistic equations in modeling real-world population growth where
resources are limited.
Question(2)
Suppose that the temperature of the surrounding environment is 70°F, and we know
from experience that a body under these conditions cools off approximately 2°F
during the first hour after death. Find a formula for the time of death.(Use Newton's law
of cooling)
Where:
This law is used in various applications, such as forensic science (to determine the time of death) and engineering
(to study heat dissipation).
Problem Statement:
A human body initially at 98.6°F is placed in an environment with a constant temperature of 70°F. After 1 hour,
the body’s temperature drops to 96.6°F. According to Newton’s Law of Cooling:
We need to find the temperature function T(t) and the cooling constant k.
Solution Methodology:
1. Define the differential equation in MATLAB.
2. Solve using dsolve with appropriate initial conditions.
3. Compute the required values.
4. Display the analytical solution.
Code:
clc; clear;
% Given data
3|Page
Salsabun Bahahuti
ID-22203010
disp(sol);
4|Page
Salsabun Bahahuti
ID-22203010
grid on;
hold off;
Results:
❖ The estimated time since death is displayed in hours.
❖ The plot shows the exponential cooling curve of the body temperature.
❖ This approach is useful in forensic investigations to determine the approximate time of death.
Conclusion:
This MATLAB script models body cooling using Newton’s Law of Cooling. It calculates the cooling constant and
predicts temperature changes over time, showing how the body cools toward the surrounding temperature.
Question(3)
Suppose that we have a gold mining operation and we are storing our tailings in a
pond that has an initial volume of 20,000 cubic meters. When we begin our operation,
the tailings pond is filled with clean water. The pond has a stream flowing into it, and
water is also pumped out of the pond. Chemicals are used in processing gold ore.
These chemicals such as sodium cyanide are often highly poisonous and dangerous
to the environment, the water must be treated before it is released into the watershed.
Suppose that 1000 cubic meters per day flow into the pond from stream and 1000
cubic meters are pumped from the pond each day to be processed and recycled.
Thus, the water level of the pond remains constant. At time t = 0, the water from
stream becomes contaminated with chemicals from the mining operation, say at a rate
of 5 kilograms of chemicals per 1000 cubic meters. We will assume that water in our
tailings pond is well mixed so that the concentration of chemicals throughout the
pond is fairly uniform. In addition, any particulate matter pumped into the pond from
the stream settles to the bottom of the pond at a rate of 50 cubic meters per day .Find
the time the pond fully chemical free.
5|Page
Salsabun Bahahuti
ID-22203010
Problem Statement:
This problem can be modeled using a differential equation for the concentration of chemicals in the pond over time.
We are given:
The concentration of chemicals in the pond at any given time depends on the rate at which chemicals enter and
exit the pond. This can be modeled using the following differential equation, based on the principle of mass balance:
This equation expresses the rate of change of the chemical concentration in the pond over time, considering both
the influx of chemicals from the stream and the outflux of water containing chemicals.
At time t = 0, there are no chemicals in the pond. So the initial condition is:
Solution Methodology
1. Define the differential equation in MATLAB.
2. Solve using dsolve with appropriate initial conditions.
3. Compute the required values.
4. Display the analytical solution
Code:
clc; clear;
% Given data
V = 20000; % Volume of pond
Q_in = 1000; % Inflow rate
Q_out = 1000; % Outflow rate
C_in = 5; % Contaminant concentration (kg/m^3)
c0 = 0; % Initial contaminant
% Display solution
disp(sol);
% To find when the pond is fully chemical-free, we set C(t) = 0 and solve
% for t
disp(t_chemical_free)
7|Page
Salsabun Bahahuti
ID-22203010
Results:
❖ The pond will be fully chemical-free after 100 days.
Conclusion:
This MATLAB script models the decrease in contaminant concentration in a pond over time. It calculates when the
pond becomes chemical-free and visualizes the decay. The results show a gradual reduction in contaminants,
demonstrating effective dilution and removal
Question(4)
A 600-gallon tank initially contains 200 liters of water containing 10 kilograms of salt.
Supposed that water containing 0.1 kilograms of salt flows into the top of the tank at a
rate of 10 liters per minute. The water in the tank is kept well mixed, and 5 liters per
minute are removed from the bottom of the tank. how much salt is in the tank when the
tank is full?
Problem Statement:
Let:
Since more water is added than removed, the total volume increases over time:
8|Page
Salsabun Bahahuti
ID-22203010
V(t)=200+(10−5)t=200+5t
The rate of change of salt in the tank is given by: dQ/dt=(Salt in)−(Salt out)
dQ/dt=(0.1×10)−(Q/V×5)
dQ/dt=1−5Q/(200+5t)
Solution Methodology:
1. Define the differential equation in MATLAB.
2. Solve using dsolve with appropriate initial conditions.
3. Compute the required values.
4. Display the analytical solution.
Code:
clc;
clear all;
syms Q(t) t;
% Given data
V_initial = 200; % Initial volume (liters)
Q0 = 10; % Initial salt amount (kg)
inflow_rate = 10; % Inflow rate (liters/min)
outflow_rate = 5; % Outflow rate (liters/min)
salt_concentration_in = 0.1; % kg per liter
% Display results
fprintf('The tank will be full in %.2f minutes.\n', t_full_numeric);
9|Page
Salsabun Bahahuti
ID-22203010
fprintf('The amount of salt in the tank when it is full: %.2f kg\n', Q_full_numeric);
Result:
❖ The tank will be full in approximately 414.20 minutes.
Conclusion:
This MATLAB code successfully models the salt concentration in a tank as it fills over time. It calculates the time
required for the tank to reach full capacity and determines the final amount of salt in the tank.
10 | P a g e
Salsabun Bahahuti
ID-22203010
11 | P a g e