What am I missing here? I have included all the parameters into my script but I still get zero as my answer. See script below
Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’);Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’); Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’); 1st order ordinary differential equations MATLAB Answers — New Questions