Question: Solve using matlab PROBLEM 4 The amount of mass transported via a pipe over a period of time can be computed as M = t

Solve using matlab
PROBLEM 4
The amount of mass transported via a pipe over a period of time can be computed as
M=t1t2Q(t)c(t)dt
where M= mass (mg),t1= the initial time ({:min),t2= the final time (min),Q(t)= flow rate (m3min), and c(t)= concentration
(mgm3). The following functional representations define the temporal variations in flow and concentration:
Q(t)=9+5cos2(0.4t)
c(t)=5e-0.5t+2e0.15t
Determine the total mass passing through the pipe within the first 15 seconds. Compare Romberg integral with Simpson's 38 Rule.
Use the following function files to help solve
function EI = IntSimp38(x,y)
% Integral - Simpsons 3/8 Rule
% using Least-Squares Regression
%Input List
% x = independent data stream
% y = dependent data stream
%Output List
% EI = sum of integral segments
N = length(x);
Q = floor(1/3*(N-1));
I = zeros(Q,1);
for q =1:Q
i =3*(q-1)+1;
A = LSRegPoly(x(i:i+3),y(i:i+3),3);
I(q)=1/4*A(1)*(x(i+3)^4- x(i)^4)...
+1/3*A(2)*(x(i+3)^3- x(i)^3)...
+1/2*A(3)*(x(i+3)^2- x(i)^2)...
+ A(4)*(x(i+3)- x(i));
end
EI = sum(I);
if i+3 N
EI = EI + IntSimp13(x(i+3:N),y(i+3:N));
end
end
function EI = Romberg(x1,y1,x2,y2)
% Integral - Newton-Cotes Polynomial
% using Least-Squares Regression
%Input List
% x1= independent data stream #1
% y1= dependent data stream #1
% x2= independent data stream #2
% y2= dependent data stream #2
%Output List
% EI = sum of integral segments
N = length(x1);
if nargin ==2 && mod(N,2)
x2= x1(1:2:end);
y2= y1(1:2:end);
end
dx1= x1(2)- x1(1);
dx2= x2(2)- x2(1);
Ia1= NewtonCotes(x1,y1,1);
Ia2= NewtonCotes(x2,y2,1);
%note spacing should be uniform!
EI = Ia2+(Ia2- Ia1)/((dx1/dx2)^2-1);
end
Solve using matlab PROBLEM 4 The amount of mass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!