Question

Read the sample Matlab code euler.m. Use either this code, or write your own code, to solve first order ODE = f(t,y) dt (a).

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

A)%%% Matlab code

clc;
close all;
clear all;
f=@(y) y^4-5*y^3+6*y^2;
t=0:0.01:2;
y(1,:)=[-2 -0.1 0 0.3 1.5];
for k=1:length(y(1,:))
for n=1:length(t)-1
y(n+1,k)=y(n,k)+0.01*f(y(n,k));
end
plot(t,y(:,k));
hold on
xlabel('t')
ylabel('y')


end
legend('y(0)=-2','y(0)=-0.1','y(0)=0','y(0)=0.3','y(0)=1.5');
%

OUTPUT:

2 y(0)-2 у(0)--0.1 1.5 y(0)=1.5 0.5 -0.5 -1 -2 0 0.2 0.40.6 0.8 1 1.2 1.416 1.8 2

(b)

clc;
close all;
clear all;
f=@(t,y)cos(t)*( y^4-5*y^3+6*y^2);
t=0:0.01:2;
y(1,:)=[-0.6 -0.1 0 0.3 0.8];
for k=1:length(y(1,:))
for n=1:length(t)-1
y(n+1,k)=y(n,k)+0.01*f(t(n),y(n,k));
end
plot(t,y(:,k));
hold on
xlabel('t')
ylabel('y')


end
legend('y(0)=-0.6','y(0)=-0.1','y(0)=0','y(0)=0.3','y(0)=0.8');
%

OUTPUT:

2 y(0)-0.6 y(0)-0.1 1.5 -y(0)-0.3 (0)=0.8 0.5 -0.5 -1 0 0.2 0.40.6 0.8 1 1.2 1.416 1.8 2

Add a comment
Know the answer?
Add Answer to:
Read the sample Matlab code euler.m. Use either this code, or write your own code, to solve first...
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
  • Hello These are a math problems that need to solve by MATLAB as code Thank you...

    Hello These are a math problems that need to solve by MATLAB as code Thank you ! Initial Value Problem #1: Consider the following first order ODE: dy-p-3 from to 2.2 with y() I (a) Solve with Euler's explicit method using h04. (b) Solve with the midpoint method using h 0.4. (c) Solve with the classical fourth-order Runge-Kutta method using 0.4 analytical solution of the ODE is,·? solution and the numerical solution at the points where the numerical solution is...

  • Use MATLAB’s ode45 command to solve the following non linear 2nd order ODE: y'' = −y'...

    Use MATLAB’s ode45 command to solve the following non linear 2nd order ODE: y'' = −y' + sin(ty) where the derivatives are with respect to time. The initial conditions are y(0) = 1 and y ' (0) = 0. Include your MATLAB code and correctly labelled plot (for 0 ≤ t ≤ 30). Describe the behaviour of the solution. Under certain conditions the following system of ODEs models fluid turbulence over time: dx / dt = σ(y − x) dy...

  • help with matlab I dt2 7. Use the second order solver method (the symbolic one) to...

    help with matlab I dt2 7. Use the second order solver method (the symbolic one) to solve the two following ODES dy dy (a) + + 16y = 0 dt day dy (b) + 16 = 0 dt2 dt both with initial conditions y(0) = 10, y'(0) = 0 and plot their solutions. These ODEs can model the position of a pendulum swinging through a fluid, where one equation represents the pendulum being in molasses, and the other is 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...

  • write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle...

    write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form....

  • Use the attached Matlab code as a basis to solve the following ordinary differential equation usi...

    Question 1 QUESTION 2 Use the attached Matlab code as a basis to solve the following ordinary differential equation using Euler's method, with timestep of 0.1, from t-0to t-100. d)0) -0 - sin (5vt cos(у Plot y versus t from t=0 to t=100. How many local maxima are on this interval(do not include end points). Be careful to count them all! Answer should be an integer 1 w% Matlab code for the solution of Module 2 3 dt-9.1; %dt is...

  • where is says use euler2, for that please create a function file for euler method and use that! please help out with t...

    where is says use euler2, for that please create a function file for euler method and use that! please help out with this! please! screenahot the outputs and code! thanks!!! The van der Pol equation is a 2nd-order ODE that describes self-sustaining oscillations in which energy is withdrawn from large oscilations and fed into the small oscillations. This equation typically models electronic circuits containing vacuum tubes. The van der Pol equation is: dy dt where y represents the position coordinate,...

  • I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT...

    I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT WE HAVE A SUB AND HE DIDN'T TEACH IT! ITS EULER AND IMPROVED EULER IN MATLAB! HERE IS THE LINK FOR THE IMAGE FILE THAT SHOWS THE FULL INSTRUCTIONS FOR THE CODE. https://imgur.com/a/gjmypLs Also, here is my code so far that I borrowed form an old assignment but the data is all wrong and the application of the code is slightly different so either...

  • using matlab thank you 3 MARKS QUESTION 3 Background The van der Pol equation is a 2nd-order ODE that describes self-sustaining oscillations in which energy is withdrawn from large oscillations and fe...

    using matlab thank you 3 MARKS QUESTION 3 Background The van der Pol equation is a 2nd-order ODE that describes self-sustaining oscillations in which energy is withdrawn from large oscillations and fed into the small oscillations. This equation typically models electronic circuits containing vacuum tubes. The van der Pol equation is: dt2 dt where y represents the position coordinate, t is time, and u is a damping coefficient The 2nd-order ODE can be solved as a set of 1st-order ODEs,...

  • Solve using R and show R code Instruction: Please submit your R code along with a...

    Solve using R and show R code Instruction: Please submit your R code along with a brief write-up of the solutions. Some of the questions below can be answered with very little or no programming. However, write code that outputs the final answer and dos not ryuira uper calceulatioms. Q.N. 1) The mammals data set in the MASS package records brain size and body size of 62 different mammals a) Fit a regresion model to describe the relation between brain...

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
ADVERTISEMENT