×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Matlab Script Help

## Matlab Script Help

(OP)
Please see the below script I have created to solve the problem. It doesn't work. Can some one help?

clear; close all; clc;
syms x1(t) x2(t) x3(t) x4(t);
r=[-0.05 0 0.03 0.05;
0.05 -0.05 0 0;
0 0.02 -0.02 0;
0 0.03 0.02 -0.05];
D=[0;1;4;0];
X=[x1;x2;x3;x4];
odes=diff(X)==r*X+D;
x1Sol(t)=simplify(x1Sol(t));
x2Sol(t)=simplify(x2Sol(t));
x3Sol(t)=simplify(x3Sol(t));
c=X(0)==[0;0;0;0];
[x1Sol(t), x2Sol(t), x3Sol(t), x4Sol(t)]=dsolve(odes,c)

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.

For this task, 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].
Formulate system of the first order ordinary differential equations and solve it numerically, using ode45 procedure.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!