Question

In: Mechanical Engineering

This is the Matlab practice so needs Matlab code 2. Numerical Integration Consider an industrial tank...

This is the Matlab practice so needs Matlab code
2. Numerical Integration
Consider an industrial tank in the shape of an inverted cone. The radius of the tank at the top rim is 3 m, and the total height of the tank is 4 m.
The volume of the tank in m3 is given by: V = (1/3) R2 H.
The volume of liquid in the tank when filled to a height h measured from the bottom vertex is:
V = (1/3)pi* (R/H)2 h3
The Lab will consist of a single script, divided in two parts. In each part, the filling schedule will be different. A filling schedule is a function that provides flow rate, in m3 / h, as a function of time.
In Part I, your script will calculate the level of the liquid, h, after a two-hour filling schedule is completed. The filling schedule for Part I, Schedule I, is as follows:
During the first 30 minutes, the flow rate will increase linearly from zero to 10 m3 / h
During the following 60 minutes, the flow rate will stay constant at 10 m3 / h
During the last 30 minutes, the flow rate will decrease linearly from 10 m3 / h down to zero
In Part II, your script will calculate the time it takes to completely fill the tank with a different filling schedule, Schedule II, given by the equation:
Flow Rate (m3 / h) = 10 (1 - e-2t ) m3 / h
where t is time in hours, and the exponent, 2t, is dimensionless
Part I:
The volume of liquid calculated in Part I, from which the height of the liquid in the tank will be calculated, should be obtained by using the built-in function to integrate polynomials, polyint( )
Part I generates a single output to the console: "The height of the liquid after Schedule I is ____ meters."
Part II:
In Part II, your script first defines Schedule II as an anonymous function
In Part II your script calculates the volume at a given time by integrating Schedule II using the built-in function quad( )
For Option A, it is acceptable to use a loop to find the time at which the tank gets completely full. If you will use an iterative approach, check the tank volume in 0.01 hour steps
Part II generates a single output to the console: "The time required to fill up the tank with Schedule II is ____ hours."

Solutions

Expert Solution

MATLAB CODE:

clc;
clear;
R=3; %radius of tank
H=4; %tank height
% part I
q1=[20 0];    %polynomial representation for time 0-30min
q2=[20];      %polynomial representation for time 30-90min
q3=[-20 0];   %polynomial representation for time 90-120min
lm_1=[0 0.5]; %time for first schedule in hours
lm_2=[0.5 1.5]; %time for second schedule in hours
lm_3=[1.5 2]; %time for third schedule in hours
P_1=polyint(q1);
P_2=polyint(q2);
P_3=polyint(q3);
V_1=(polyval(P_1,lm_1(2))-polyval(P_1,lm_1(1)))+(polyval(P_2,lm_2(2))-polyval(P_2,lm_2(1)))+(polyval(P_3,lm_3(2))-polyval(P_3,lm_3(1)));
h=(3*V_1/(pi*(R/H)^2))^(1/3);
fprintf('The height of the liquid after Schedule I is %.3f meters\n\n\n',h);

% part II
V=1/3*pi*R^2*H;   %total volume of tank
er=1;    %initial error for starting loop
a=0;     %initial limit
b=0.01; %final limit for iteration 1
Q =@(t) 10*(1-exp(-2*t)); %flow rate function
it=0;   %iteration count
V_t=0; %volume initial
while er>0.1;
    V_t=V_t+quad(Q,a,b);   %volume filled
    er=abs(V-V_t); %error
    t=b;       %new time
    a=b;       %new limits
    b=b+0.01; %new limits
    it=it+1;   %iteration number
end
fprintf('The time required to fill up the tank with Schedule II is %.3f hours.\n',t);

SAMPLE OUTPUT:


Related Solutions

This is a numerical methods question using MATLAB. Which of the following code snippets finds the...
This is a numerical methods question using MATLAB. Which of the following code snippets finds the forward difference estimate of the derivative at each of the x values. Assume x and y have been previously defined, for example as y=[10,20,25, 27.5, 30]; x = [0.3,0.5, 0.8, 0.9, 1]; (d is the derivative variable name) Although not necessarily so, there may be more than one correct answer. a) for k=1:length(y)-1 d(k)=(y(k+1)-y(k))/(x(k+1)-x(k)); end d(k+1)=NaN b) for k=1:length(y) d(k)=(y(k+1)-y(k))/(x(k+1)-x(k)); end c) d(1)=NaN; for...
Give me a MATLAB code which integrates any function using Romberg integration The code must work...
Give me a MATLAB code which integrates any function using Romberg integration The code must work fine or else I will down vote the answer badly Dont post if you dont know
I need an original matlab code and gui for a simple double pendulum. This needs to...
I need an original matlab code and gui for a simple double pendulum. This needs to be original and not too complicated. Please provide basic instructions. Thank you!
Write a C or Matlab code for E11(1, 6), consider the point G = (2, 7)....
Write a C or Matlab code for E11(1, 6), consider the point G = (2, 7). Compute the multiples of G from 2G through 13G
Numerical Analysis: Make a matlab code that computes the Midpoint rule/method for a given function f'(t,y)...
Numerical Analysis: Make a matlab code that computes the Midpoint rule/method for a given function f'(t,y) = y' =  t + y from 0 < t < 4 (inclusive) with h=0.5 and with initial condition y(0) = 0. Please make output display in tabular form and not in a plot, that doesn't help show the actual values.
Practice for Matlab. You can create own f(x). a. Write code to find and plot a...
Practice for Matlab. You can create own f(x). a. Write code to find and plot a root using the modified secant method b. Find the roots using the roots command - identify and plot root of interest c. Use polyder and roots to find and plot the minimum value d. use fminbnd to find and plot minimum value Thank you!
The cleaning process of a certain industrial tank consists of 2 phases: • Phase 1: It...
The cleaning process of a certain industrial tank consists of 2 phases: • Phase 1: It begins by placing 2,000 L of water in the tank together with 100 kg of a certain chemical cleaner (soluble in water). • Phase 2: 40 L / min of water containing 2 kg of the cleaner per liter are poured into the tank. At the same time, the well mixed solution is pumped out of the tank at a rate of 45 L...
Using Matlab code, solve the following: (a) Consider first the undamped pendulum ? + sin ?...
Using Matlab code, solve the following: (a) Consider first the undamped pendulum ? + sin ? = 0, ?(0) = 0, ? (0) = b. Let x = ? and y = ? ; then x and y satisfy the system x = y y = ? sin x, x(0) = 0 y(0) = b. Solve this system numerically and plot, on a single graph, the resulting trajectories for the initial velocities b = 0.5, 1, 1.5, 2, 2.5. Use...
BROKEN SPEEDOMETER The cycling competition is near, so jojo needs to practice cycling. he used a...
BROKEN SPEEDOMETER The cycling competition is near, so jojo needs to practice cycling. he used a speedometer found in his basement to measure his speed. however, it turns out that the speedometer is not usual! the digits on the speedometer can only count up to 2. if we add a value to a digit 2, it will revert to 0 and adds a value to the next digit. for example, the numbers [0,1,2,3,4,5,6,7] will be shown as [0,1,2,10,11,12,20,21] on the...
Part I: Numerical Integration Evaluate the following integrals: i. ∫4(1−?−4?3 +2?5)?? 0 ii. ∫3(?2??)?? 0 a)...
Part I: Numerical Integration Evaluate the following integrals: i. ∫4(1−?−4?3 +2?5)?? 0 ii. ∫3(?2??)?? 0 a) Analytically b) Multiple application of Trapezoidal rule n = 4. c) Simpson’s 1/3 rule for n = 4. d) Simpson’s 1/3 and Simpson’s 3/8 rule for n = 5. e) Determine the true percent relative error.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT