Question: MATLAB APPLIED NUMERICAL METHOD MatLab and use a different code from the solution manual on chegg Measurements of the velocity distribution of a fluid flowing

MATLAB

APPLIED NUMERICAL METHOD

MatLab and use a different code from the solution manual on chegg

Measurements of the velocity distribution of a fluid flowing

in a pipe (laminar flow) are given in the table. The flow rate Q (vol- ume of fluid per second) in the pipe can be calculated by:

Q = J :21tvrdr

Use the data in the table to evaluate Q.

---'t? ---

(a) Use the user-defined function IntPointsTrap that was written in Problem 9. 19.

(b) Use the user-defined function SimpsonPoints that was written in Problem 9.20.

(c) Use MATLAB's built-in function trapz.

MATLAB APPLIED NUMERICAL METHOD MatLab and use a different code from the

Function for IntPointsTrap

function I=IntPointsTrap(x,y) I=0; N=length(x)-1; for i=1:N I=I+(1/2)*(y(i)+y(i+1))*(x(i+1)-x(i)); end end

Functions for Simpsons Points

function I = SimpsonPoints(x, y)

n = length(x); num_intervals = n - 1; h = x(2) - x(1); I = 0;

if mod(num_intervals, 3) == 0 for i = 1:n if i == 1 || i == n I = I + y(i); elseif mod(i, 3) == 1 I = I + 2 * y(i); else I = I + 3 * y(i); end end I = I * 3 * h / 8; elseif mod(num_intervals, 3) == 1 I_trapezoidal = (y(1) + y(2)) / 2; for i = 2:n if ((i == 2) || (i == n)) I = I + y(i); elseif mod(i, 3) == 2 I = I + 2 * y(i); else I = I + 3 * y(i); end end I = I * 3 * h / 8 + I_trapezoidal; else I_simpson = ((x(2) - x(1)) * (y(1) + 4 * y(2) + y(3))) / 3; for i = 3:n if (i == 3) || (i == n) I = I + y(i); elseif mod(i, 3) == 0 I = I + 2 * y(i); else I = I + 3 * y(i); end end I = (I * 3 * h / 8) + I_simpson; end

end

9.32 Measurements of the velocity distribution of a fluid flowing in a pipe (laminar flow) are given in the table. The flow rate Q(vol- ume of fluid per second) in the pipe can be calculated by: 2Tvrdr Use the data in the table to evaluate Q. (a) Use the user-defined function IntPointsTrap that was written in Problem 9.19. (b) Use the user-defined function Simpson Points that was written in Problem 9.20. (c) Use MATLAB's built-in function trapz. 1 1.25 1.5 1.75 2.0 r (in) 0.0 0.25 0.5 0.75 0 v (in/s) 38.0 37.6 36.2 33.6 29.7 24.5 17.8 9.6

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 Databases Questions!