Question

A storage tank (shown below) contains a liquid at depth y where y 0 when the tank is half full. Liquid is withdrawn at a cons

Can you please help with this question? Please answer the question in MATLAB coding. Thank you in advance!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

main.m

clc
clear

clc
clear

t0 = 0;
y0 = 0;
tEnd = 10;
h = 0.1;
N = (tEnd - t0)/h;
%% Initializing solution
t = [t0:h:tEnd]';
yA = zeros(N + 1, 1);
yA(1) = y0;

yB = zeros(N + 1, 1);
yB(1) = y0;
%% Solving using Euler's Explicit Method
for i = 1:N
fi = funVolA(t(i), yA(i));
yA(i + 1) = yA(i) + h*fi;
  
fiB = funVolB(t(i), yB(i));
yB(i + 1) = yB(i) + h*fiB;
end
plot(t, yA, 'r-');
hold on
plot(t, yB, 'b-');
xlabel('t');
ylabel('y');
legend('Solution A.', 'Solution A.','Location','northwest');

funVolA.m

function dy = funVolA(t, y)
Q = 450;
A = 1250;
dy = (3*Q* sin(t)^2 - Q)/A;
  
end

funVolB.m

function dy = funVolB(t, y)
Q = 450;
A = 1250;
alpha = 150;
dy = (3*Q* sin(t)^2 - alpha*(1 + y)^1.5)/A;
  
end

Output:

2 Solution A -Solution A. 1.5 0.5 -0.5 0 123 4 5 67 8 9 10

Add a comment
Know the answer?
Add Answer to:
Can you please help with this question? Please answer the question in MATLAB coding. Thank you in advance!! A storage tank (shown below) contains a liquid at depth y where y 0 when the tank is half f...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT