Question: In this question, you will explore some basic commands in MATLAB. Consider the IVP d y d x = e 2 x + y ,

In this question, you will explore some basic commands in MATLAB. Consider the IVP
dydx=e2x+y,y(0)=-1
We want to find and approximate solution on 0,0.3 using Euler's Method with
step size h=0.1.
Hint: Euler's method has the formula yi+1=yi+h*f(xi,yi). We will define the
function f using the command:
>>f=@(x,y)e2x+y
put the x-values , and 0.3
(a) Try the followings in the command window of MATLAB, and explain what
these commands do:
>>a=9
>>b=6
>>c=5*sin(b)-a2
>>d=exp(2)
>>e=log(d)
(b) In MATLAB, we can define and plot a function y=x3+x2+x+1 on the
interval 0,5 using the following commands:
>>f=@(x)x.?3+x.?2+x+1
>>x=0:0.1:5
>>y=f(x)
>>plot(x,y)
Explanation:
(1). Define the function using the function handle in MATLAB.
(2). Pick descrete x-values on 0,5 with increment 0.1.
(3). Compute the corresponding y-values.
(4). Use the plot command to draw the graph.
Please modify the commands and use them to plot the function y=ex+xcosx
on 0,3.(Make sure to include this figure in your report.)
In this question, you will explore some basic

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 Programming Questions!