Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function Euler(m,c,g,t0,v0,tn,n) % print headings and initial conditions fprintf(values of t approximations v(t) ) fprintf(%8.3f,t0),fprintf(%19.4f ,v0) % compute step size h h=(tn-t0); % set t,v

image text in transcribed

function Euler(m,c,g,t0,v0,tn,n)

% print headings and initial conditions

fprintf(values of t approximations v(t) )

fprintf(%8.3f,t0),fprintf(%19.4f ,v0)

% compute step size h h=(tn-t0);

% set t,v to the initial values

t=t0; v=v0;

% compute v(t) over n time steps using Eulers method

for i=1:n

v=v+(g-c/m*v)*h;

t=t+h;

fprintf(%8.3f,t)

fprintf(%19.4f ,v)

end

Question #2-6 Marks Newton's law of cooling says that the temperature of a body changes at a rate proportional to the difference between its temperature and that of the surrrounding medium (the ambient temperature), dT dt =-k(T-T.) where T is the temperature of the body (C), t is time (minutes), k is the proportionality constant (per minute), and Ta is the ambient temperature (C) (a) Modify the MATLAB function Euler in Question 1 so that it will use Eulers method to solve this differential equation. Use the function header function Euler2(k , Ta, t0 , TO , tn , n) where Ta-T,, the initial condition T0 = T(to), tn is the final value of t in the numerical solution, and n is the number of time steps DELIVERABLES: A copy of the M-FILE in your pdf (b) Use Euler2 to compute a numerical approximation to the above differential equation using k = 0.019/min, Ta-20C and initial condition T(0) = 68C on the time interval [0,12 using a step size of 0.125 minutes DELIVERABLES: The function call to Euler2 and the resulting output (c) Use the fact the exact analytic solution of this problem is T(t) 20+48e-0.019t to compute (either in MATLAB or using your calculator) the relative error in the computed solution at t = 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago