Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The function to be altered is below: function [t,v] = 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)

image text in transcribedThe function to be altered is below:

function [t,v] = 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(1)=t0; v(1)=v0; % compute v(t) over n time steps using Eulers method for i=1:n v(i+1)=v(i)+(g-c/m*v(i))*h; t(i+1)=t(i)+h; fprintf('%8.3f',t(i+1)),fprintf('%19.4f ',v(i+1)) end 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 di = -k(T - T.) where T is the temperature of the body (C), t is time (minutes), k is the proportionality constant (per minute), and T, is the ambient temperature (C). (a) Modify the MATLAB function Euler in Question 1 so that it will use Euler's method to solve this differential equation. Use the function header function Euler2(k , Ta, to , TO, tn , n) where Ta = Ta, the initial condition TO = 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, T, = 20C and initial condition T(0) = 68C on the time interval 10, 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.019 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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago