Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have never used MATLB for anything this complicated, please include some notes with the code. ential equation (t)=f[x(t)] Ean (1) We want to compare

I have never used MATLB for anything this complicated, please include some notes with the code.image text in transcribed

ential equation (t)=f[x(t)] Ean (1) We want to compare between the solution of a differential equation And it's equivalent difference equation x(k+1) = x(k) + T f [x(k)] Eqn (2) a) Forf [x(t)]=-x(t) +cos(t) write code to obtain the solution of the differential equation given by equation (1) and the difference equation given by equation (2). You will need to create Matlab code for the iterative solution to the difference equation. Paste your code in the entry block below. b) Compare between the two solutions for three different values of the sampling time. State (in the entry block below) what happens to the difference solution as the sample time varies? Hint: To solve a differential equation, you can use ode45, which is a built in MATLAB function. An example is provided below (for a different function. There are two files. The first contains the function we want to solve and the second file calls the first file during run time. Feel free to pick the initial conditions. An example is shown in figure 1 where f [x(t)]=-x(t) + sin(t) for T = 0.1 sec and x(0) = 2. Fig. 1. Comparison between solution of differential and difference equations. The "to be solved" function: Function f=hwlfunction(t,x,user) % This function is saved as hwlfunction.m f=zeros(1,1) Erstsin(t) The run-time script calling the function: x0=[2] % Initial condition FinalTime=5 % Final Time InitialTime=0 % Initial Time figure(1) options=odeset('reltol,0.001, Stats','on'); [t,y]=ode45(@hwlfunction, [InitialTime FinalTime), [x0]; Plot(t,y(),'m'), hold on

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago