Question

Using Matlab, solve the following ODE using Euler's method... I have to perform solve the ODE...

Using Matlab, solve the following ODE using Euler's method...

I have to perform solve the ODE with both step sizes and plot both on the same graph.

y'=1/y, Initial Condition y(0)=1. step size = 0.1 and 0.01

The interval is from 0 to 1.

UPDATE: I actually figured it out myself! THANKS

Homework Answers

Answer #1

% We will solve this problem by Euler's Method

clc;

clear all;

h = 0.1; % initial step size

for j=1:2

x = 0:h:1; % the range of x

y = zeros(size(x)); % allocate the result y

y(1) = 1; % the initial y value

n = numel(y); % the number of y values

% The loop to solve the DE

for i=1:n-1

f = 1/(y(i)); % The given function

y(i+1) = y(i) + h * f; % formula for Euler's method.

end

plot(x,y)

hold on

h=h*0.1;

end

Know the answer?
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
Similar Questions
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method...
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method (use the form of second-order Runge-Kutta method, Eqs(10.65),(10.66)). For function name and arguments use [x,y]=odeMIDPOINT(ODE,a,b,h,yINI). The input argument ODE is a name for the function that calculates dy/dx. It is a dummy name for the function that is imported into odeMIDPOINT. The arguments a and b define the domain of the solution, h is step size; yINI is initial value. The output arguments, x...
Euler's Method in Matlab How should I put y'=3cos(t)-2y; y(0)=0 in Matlab, we needed to see...
Euler's Method in Matlab How should I put y'=3cos(t)-2y; y(0)=0 in Matlab, we needed to see the approximate and the exact graph of the equation. As much as possible, I need the whole script to run it and please also specify important notes. Thank you so much.
(a) Use Euler's method with each of the following step sizes to estimate the value of...
(a) Use Euler's method with each of the following step sizes to estimate the value of y(0.4), where y is the solution of the initial-value problem y' = y, y(0) = 9. (i)    h = 0.4 y(0.4) =   (ii)    h = 0.2 y(0.4) =   (iii)    h = 0.1 y(0.4) =   (c) The error in Euler's method is the difference between the exact value and the approximate value. Find the errors made in part (a) in using Euler's method to estimate the true value...
a)Program a calculator or computer to use Euler's method to compute y(1), where y(x) is the...
a)Program a calculator or computer to use Euler's method to compute y(1), where y(x) is the solution of the given initial-value problem. (Give all answers to four decimal places.) dy dx + 3x2y = 9x2, y(0) = 4 h = 1     y(1) = h = 0.1     y(1) = h = 0.01     y(1) = h = 0.001     y(1) = (b) Verify that y = 3 + e−x3 is the exact solution of the differential equation. y = 3 + e−x3      ⇒     y'...
Using Matlab, evaluate ? = (? + 10) (?^5 + 1) for values of x in...
Using Matlab, evaluate ? = (? + 10) (?^5 + 1) for values of x in the range of -1 to 1 in step sizes of 0.1. Hence, plot y versus x. Could you also include the Matlab code and the associated screenshots?
Given the initial value problem: y'=6√(t+y),  y(0)=1 Use Euler's method with step size h = 0.1 to...
Given the initial value problem: y'=6√(t+y),  y(0)=1 Use Euler's method with step size h = 0.1 to estimate: y(0.1) = y(0.2) =
Use Euler's method with step size 0.1 to estimate y(0.5), where y(x) is the solution of...
Use Euler's method with step size 0.1 to estimate y(0.5), where y(x) is the solution of the initial-value problem y'=3x+y^2,   y(0)=−1 y(0.5)=
Using euler's forward method solve this integration: dx/dt = -10 * x(t) + 5 x(0) =...
Using euler's forward method solve this integration: dx/dt = -10 * x(t) + 5 x(0) = 4 The time step is 0.01, and the time interval is from 0 to 20. Please show all steps and calculations, because this is just an example problem to help me get a better understanding of euler's method.
I need to make a model in MATLAB for free-fall using Euler method. g=9.81 (gravitational acceleration)...
I need to make a model in MATLAB for free-fall using Euler method. g=9.81 (gravitational acceleration) c=12.5 (drag coefficient) m= 68.1 (mass) h=0.1 (step size) v(0)=0 (Velocity is 0 at time zero) t=[0:100]*h (100 steps) Vnew= vt+(g-(c/m)*v)*h (this is the equation for the velocity at each subsequent step I want to use a "for" loop in MATLAB but i don't know how to write it properly. Could anyone help me?
You can use dsolve in MATLAB...run simplify(...) on the solution...You should plot the homogeneous and the...
You can use dsolve in MATLAB...run simplify(...) on the solution...You should plot the homogeneous and the inhomogeneous solutions on the same graph, using the "plot" function of MATLAB. set the arbitrary constants to 1 Consider the homogeneous equation y'' + 3y' + 2y = 0. a) Solve it and set the c's to 1. Graph this transient solution using large dots in MATLAB. b) Now add on the right-hand side the linear term 12x. Solve the inhomogeneous equation y'' +...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT