Question

please writed a code using matlab that performs modified eulers method and do the following

2. Use the code to solve the following problem. y = 1+ 15t52. y(1) = 2, Exact Solution y(t) = ?Int + 21. (a) Run the code for

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format long
t=2;
f=@(t,y) 1+y/t;
hold on;
for N=[10,20,100]
[T,Y]=euler_modified(f,1,2,2,N);
fprintf('FOr N=%d, At t=2, Y(2) is %f,error is %.4e\n',N,Y(end),abs(Y(end)-2*log(t)-2*t));
plot(T,Y);
end
legend('N=10','N=20','N=100')
function [T,Y] = euler_modified(f,x0,xn,y0,n)
h=(xn-x0)/n;
T=[];
Y=[];
while x0<=xn
T=[T x0];
Y=[Y y0];
k=y0+h*f(x0,y0);
x1=x0+h;
y1=y0+h/2*(f(x0,y0)+f(x1,k));
x0=x1;
y0=y1;
end
end

MATLAB R2018a Figure 1 X Search Documentation Pradeep EDITOR НOME PLOTS APPS fEile Edit View Insert Tools Desktop Window Help

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
please writed a code using matlab that performs modified eulers method and do the following 2....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Differential Equation (5 points) Using (i) Euler's method and (ii) modified Euler's method, bo...

    Please show Matlab code and Simulink screenshots 2. Differential Equation (5 points) Using (i) Euler's method and (ii) modified Euler's method, both with step size h-0.01, to construct an approximate solution from t-0 to t-2 for xt 2 , 42 with initial condition x(0)-1. Compare both results by plotting them in the same figure. 3. Simulink (5 points) Solve the above differential equation using simplink. Present the model and result. 2. Differential Equation (5 points) Using (i) Euler's method and...

  • di 2 y(0) = 1 Matlab. Apply Eulers method with step size h = 0.1 on...

    di 2 y(0) = 1 Matlab. Apply Eulers method with step size h = 0.1 on [0, 1] to the initial value problem listed above, in #3. a Print a table of the t values, Euler approximations, and error at each step. Deduce the order of convergence of Euler's method in this case.

  • 1 st s2, y(1)1 The exact solution is given by yo) - = . 1+Int Write a MATLAB code to approximate ...

    1 st s2, y(1)1 The exact solution is given by yo) - = . 1+Int Write a MATLAB code to approximate the solution of the IVP using Midpoint (RK2) and Modified Euler methods when h [0.5 0.1 0.0s 0.01 0.005 0.001]. A) Find the vector w mid and w mod that approximates the solution of the IVP for different values of h. B) Plot the step-size h versus the relative error of both in the same figure using the LOGLOG...

  • Solve the following utilizing MATLAB code. must provide the inputs and outputs of the function. the function should be able to solve such problem using Eulers method, in which after solving must p...

    Solve the following utilizing MATLAB code. must provide the inputs and outputs of the function. the function should be able to solve such problem using Eulers method, in which after solving must plot the results Problem 5: The logistic model is used to simulate population as in Pmax Where p population, kgm the maximum growth rate under unlimited conditions, and рта? the carrying capacity. Simulate the world's population from 1950 to 2000 using one of the numerical methods discussed in...

  • I mostly needed help with developing matlab code using the Euler method to create a graph. All th...

    I mostly needed help with developing matlab code using the Euler method to create a graph. All the other methods are doable once I have a proper Euler method code to refer to. 2nd order ODE of modeling a cylinder oscillating in still water wate wate Figure 1. A cylinder oscillating in still water. A cylinder floating in the water can be modeled by the second order ODE: dy dy dt dt where y is the distance from the water...

  • Numerical Analysis: Make a matlab code that computes the Modified Euler's method for a given function...

    Numerical Analysis: Make a matlab code that computes the Modified Euler's method for a given function y' =  t + y from 0 < t < 4 (inclusive) with h=0.5 and with initial condition y(0) = 0. Please make output display in tabular form and not in a plot, that doesn't help show the actual values.

  • The Program for the code should be matlab 5. [25 pointsl Given the initial value problem...

    The Program for the code should be matlab 5. [25 pointsl Given the initial value problem with the initial conditions y(0) 2 and y'(0)10, (a) Solve analytically to obtain the exact solution y(x) (b) Solve numerically using the forward Euler, backward Euler, and fourth-order Runge Kutta methods. Please implement all three methods yourselves do not use any built- in integrators (i.e., ode45)). Integrate over 0 3 r < 4, and compare the methods with the exact solution. (For example, using...

  • SOLVE USING MATLAB Problem 22.1A. Solve the following initial value problem over the interval fromt 0...

    SOLVE USING MATLAB Problem 22.1A. Solve the following initial value problem over the interval fromt 0 to 5 where y(0) 8. Display all your results on the same graph. dt The analytical solution is given by: y(0) - 4e-0.5t (a) Using the analytical solution. (b) Using Eulers method with h 0.5 and 0.25 (c) Using the midpoint method with h 0.5. (d) Using the fourth-order RK method with h 0.5.

  • Matlab & Differential Equations Help Needed I need help with this Matlab project for differential equations. I've got 0 experience with Matlab other than a much easier project I did in another...

    Matlab & Differential Equations Help Needed I need help with this Matlab project for differential equations. I've got 0 experience with Matlab other than a much easier project I did in another class a few semesters ago. All we've been given is this piece of paper and some sample code. I don't even know how to begin to approach this. I don't know how to use Matlab at all and I barely can do this material. Here's the handout: Here's...

  • SOLVE NUMERICALLY USING EULERS METHOD

    The motion of a damped spring-mass system (Fig. P25.16)  is described by the following ordinary differential equation: m d2x dt2 1 c dx dt 1 kx 5 0 where x 5 displacement from equilibrium position (m), t 5 time  (s), m 5 20-kg mass, and c 5 the damping coeffi cient (N ? s/m).  The damping coeffi cient c takes on three values of 5 (underdamped), 40 (critically damped), and 200 (overdamped). The  spring constant k 5 20 N/m. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT