0% found this document useful (0 votes)
2 views

MATLAB (Part-B) Prome

The document discusses four mathematical modeling problems using MATLAB: the logistic growth of fish in a pond, the cooling of a body using Newton's law, the contamination of a tailings pond, and the salt concentration in a tank. Each problem includes a detailed methodology for setting up and solving differential equations, along with MATLAB code and results. The conclusions highlight the practical applications of these models in real-world scenarios.

Uploaded by

aimtiazm2017.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MATLAB (Part-B) Prome

The document discusses four mathematical modeling problems using MATLAB: the logistic growth of fish in a pond, the cooling of a body using Newton's law, the contamination of a tailings pond, and the salt concentration in a tank. Each problem includes a detailed methodology for setting up and solving differential equations, along with MATLAB code and results. The conclusions highlight the practical applications of these models in real-world scenarios.

Uploaded by

aimtiazm2017.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Prome Rudra

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:

• P is the population at time t,


• k is the intrinsic growth rate,
• K is the carrying capacity of the environment.

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:

• - K = 2000 (maximum capacity),


• - P0 = 80 (initial population),
• - k = 0.3 (growth rate).

We need to find the population at any time t.

Solution Methodology
1. Define the logistic growth equation in MATLAB using symbolic math.

2. Solve the differential equation using dsolve.

3. Apply the initial condition P(0) = 80.

4. Display the analytical solution.

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 =

K = 2000; % Carrying Capacity


k = 0.3; % Growth rate(constant)
t = 0:1:100; % Time vector (from 0 to 100,with steps of 1)

% Logistic Population Model equation


P_t = K./(exp(K.*(log(K/100-1)/K-(k*t)/K))+1);

% Plot the population over time


figure;
plot(t,P_t, 'LineWidth',2);
xlabel('Time (t)');
ylabel('Population of fish (P(t))');
title('Fish Population in the Pond Over Time (Constant Growth Rate)');
grid on;

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)

Newton's Law of Cooling:


Newton’s Law of Cooling states that the rate of heat loss of a body is proportional to the difference in temperature
between the body and its surroundings. The equation is:

Where:

• T is the temperature of the body at time t,


• is the ambient temperature,
• k is a constant that depends on the properties of the material.

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:

dT/dt = -k(T - T_m)

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

T_m = 70; % Surrounding Temperature


T_initial = 98.6; % Body Temperature
T_x =T_initial-2; % Temperature after 1 hour

% Newton's cooling law:dT/dt = -k*(T-T_m)


syms T(t) k
eq = diff(T) == -k* (T-T_m);

% Solve for T(t)


sol = dsolve(eq, T(0) == T_initial);
disp('Temperature function T(t):');

Temperature function T(t):

disp(sol);

% Solve for k using T(1) =T_x


k_value = solve(subs(sol, t, 1) == T_x, k);
disp(k_value);

% Substitute k into the solution


final_sol = subs(sol, k, k_value);

% Display the Solution


disp(final_sol);

% Convert symbolic solution to numerical function


T_func = matlabFunction(final_sol);

% Define time range


time = 0:0.1:10;
temperature = T_func(time);

% Plot the temperature function


plot(time, temperature, 'b', 'LineWidth', 2);
hold on;
yline(T_m, 'r--'); % Ambient temperature reference line
xlabel('Time (hours)');
ylabel('Temperature (°F)');
title('Cooling Curve');

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 pond’s volume, = 20,000 m³


• The inflow rate of water, = 1000 m³/day
• The outflow rate of water, = 1000 m³/day
• The concentration of chemicals in the incoming water, = 5 kg per 1000 m³
• The initial concentration of chemicals in the pond, = 0 kg

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

% Define the differential equation dc/dt = (Q_in*C_in - Q_out*C) /V


syms C(t)
eqn = diff(C) == (Q_in *C_in -Q_out *C)/ V;

% Solve the differential equation with initial condition C(0) =c0


6|Page
Salsabun Bahahuti
ID-22203010

sol = dsolve(eqn, C(0) ==c0);

% Display solution
disp(sol);

% To find when the pond is fully chemical-free, we set C(t) = 0 and solve
% for t

t_chemical_free = solve(sol == 0, t);

disp('Time when the pond is fully chemical-free (t):')

Time when the pond is fully chemical-free (t):

disp(t_chemical_free)

% Convert symbolic solution to numerical function


C_func = matlabFunction(sol);

% Define time range


time = 0:10:1000; % Time in seconds

% Plot the concentration function


plot(time, C_func(time), 'b', 'LineWidth', 2);
xlabel('Time (seconds)');
ylabel('Contaminant Concentration (kg/m^3)');
title('Contaminant Concentration in the Pond');
grid on;

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:

• V(t) be the volume of water in the tank at time t.


• Q(t) be the amount of salt in the tank at time t.
• The tank initially contains 200 liters of water with 10 kg of salt.
• Water containing 0.1 kg/L of salt flows in at 10 L/min.
• Water is removed at 5 L/min.

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 salt concentration in the tank is:Q(t)/V(t)

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

% Volume of water as function of time


V = V_initial + (inflow_rate - outflow_rate) * t;

% Define the differential equation


eqn = diff(Q, t) == (salt_concentration_in * inflow_rate) - (outflow_rate / V) * Q;

% Solve the differential equation using dsolve


sol = dsolve(eqn, Q(0) == Q0);

% Find Q when the tank is full (600 gallons = 2271 liters)


t_full = solve(V == 2271, t); % Find time when tank is full
Q_full = subs(sol, t, t_full); % Compute salt amount at that time

% Convert to numeric values


t_full_numeric = double(t_full);
Q_full_numeric = double(Q_full);

% Display results
fprintf('The tank will be full in %.2f minutes.\n', t_full_numeric);

The tank will be full in 414.20 minutes.

9|Page
Salsabun Bahahuti
ID-22203010

fprintf('The amount of salt in the tank when it is full: %.2f kg\n', Q_full_numeric);

The amount of salt in the tank when it is full: 226.22 kg

% Plot the salt amount over time


fplot(sol, [0, t_full_numeric + 10], 'b', 'LineWidth', 2);
hold on;
plot(t_full_numeric, Q_full_numeric, 'ro', 'MarkerSize', 8, 'LineWidth', 2); % Mark full
tank
xlabel('Time (minutes)');
ylabel('Salt in Tank (kg)');
title('Salt Amount in Tank Over Time');
grid on;
legend('Salt Amount Q(t)', 'Tank Full Point');
hold off;

Result:
❖ The tank will be full in approximately 414.20 minutes.

❖ The amount of salt in the tank when it is full: 226.22 kg.

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

You might also like