Question: I'm having difficult with question 4 the matlab question. I have to make a matlab code using the function above. Q2 function [t,V] = tankVolume()

 I'm having difficult with question 4 the matlab question. I have

I'm having difficult with question 4 the matlab question.

to make a matlab code using the function above. Q2 function [t,V]

I have to make a matlab code using the function above.

Q2

function [t,V] = tankVolume() A=4; a=0.1; g=9.81; V0=10; tspan=[0 50]; [t,V]=ode45(@(t,V) 0.7*exp(-0.1*t)-a*sqrt((2*g*V)/A),tspan,V0); end

Q3

function [t,y] = modifiedEuler(f,tspan,y0,N) %Initialization h = (tspan(2)-tspan(1))/N; %h=(b-a) t = tspan(1):h:tspan(2); %t_i=a+h*i y = y0*ones(size(t)); %y(0)=y0 is set for i=1:N ypred = y(i) + h*f(t(i),y(i)); %y_i+1 prediction with euler y(i+1) = y(i) + h*(f(t(i),y(i))+f(t(i+1),ypred))/2; %correction end end

Thses are the matlab codes for Q2 and Q3 that are already solved . Please use these codes if necessary.

No spamming answers please i need a serious answer. Thank you

In the last portfolio task, we modelled water draining from a tank with a small hole in the bottom. To slow the volume decrease of the tank, a hose is placed in the top of tank with flow rate Q(t). This results in the following modified Torcelli's law: dV dt Given A -4 m2, a0.1 m2, g V(0) = 10 m2, 9.81 m/s, Q(t)0.7e0 m3s and 1. Explain why this ODE cannot be solved analytically using separation or the integrating factor 2. (AMS Submission) Write a MATLAB function that solves the ODE using MLATLAB's ode45 from t = 0 to t = 50 3. (AMS Submission) Create a MATLAB function that can numerically solve a first order ODE using the Modified Euler Method. The function should share the same inputs and outputs in the function declaration as the Euler Method Example covered in the week 8 lecture 4. (AMS Submission) Using your code from Question 3, investigate the effect of the step size by solving the ODE using N 10,20, 40, 80. Plot all 4 numerical solutions and the ODE45 solution on the same figure, 5. Comment on the impact of halving step size (ie. doubling N) on the ac- curacy of the numerical solution. You can assume the ODE45 solution to be considered sufficiently exact in this comparison In the last portfolio task, we modelled water draining from a tank with a small hole in the bottom. To slow the volume decrease of the tank, a hose is placed in the top of tank with flow rate Q(t). This results in the following modified Torcelli's law: dV dt Given A -4 m2, a0.1 m2, g V(0) = 10 m2, 9.81 m/s, Q(t)0.7e0 m3s and 1. Explain why this ODE cannot be solved analytically using separation or the integrating factor 2. (AMS Submission) Write a MATLAB function that solves the ODE using MLATLAB's ode45 from t = 0 to t = 50 3. (AMS Submission) Create a MATLAB function that can numerically solve a first order ODE using the Modified Euler Method. The function should share the same inputs and outputs in the function declaration as the Euler Method Example covered in the week 8 lecture 4. (AMS Submission) Using your code from Question 3, investigate the effect of the step size by solving the ODE using N 10,20, 40, 80. Plot all 4 numerical solutions and the ODE45 solution on the same figure, 5. Comment on the impact of halving step size (ie. doubling N) on the ac- curacy of the numerical solution. You can assume the ODE45 solution to be considered sufficiently exact in this comparison

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!