Program Screen Shot:
Sample Output:
Program Code to Copy:
function dY = ode_fun(t,Y)
%%
%{
from: y'' + 5y + 4y = 0, y(0) = 0, y'(0) = 6
let: y' = x
meaning two 1st order ode's are formed as:
x' = -5x - 4y, x(0) = y'(0) = 6
y' = x, y(0) = 0
%}
%
%% % extract x and y in the same order initial conditions were
set
x = Y(1); y = Y(2);
%
%% compute the derivatives
dx = -5*x - 4*y; % for x'
dy = x; % for y'
%
dY = [dx;dy];
end
______________________________________________
% driver_file.m
clc,clear,close all
%%
%{
from: y'' + 5y + 4y = 0, y(0) = 0, y'(0) = 6
let: y' = x
meaning two 1st order ode's are formed as:
x' = -5x - 4y, x(0) = y'(0) = 6
y' = x, y(0) = 0
%}
%% set the initial conditions and time interval
x0 = 6; y0 = 0;
Y0 = [x0;y0]; % initial conditions
tspan = [0 10]; % time interval
%% solve numerically
[t,Y] = ode45(@ode_fun,tspan,Y0); % using ode45
%% extract the numerical solution
y_num = Y(:,2); % 2nd colum contains the solution y
dydt_num = Y(:,1); % 1st column contains the solution dydt
%% compute the true y and dydt solutions
y_true = 2.*exp(-t) - 2.*exp(-4*t);
dydt_true = -2.*exp(-t) + 8.*exp(-4*t);
%% graph the results
figure,plot(t,y_num,'o b',t,y_true,'-
r'),xlabel('t'),ylabel('y(t)')
legend('y_n_u_m','y_t_r_u_e'),grid on
%
figure,plot(t,dydt_num,'o b',t,dydt_true,'-
r'),xlabel('t'),ylabel('dydt')
legend('dydt_n_u_m','dydt_t_r_u_e'),grid on
%%
------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~
only using matlab Osts 10 Problem 3 Numerically integrate the 2nd order linear differential equation on...
mat lab only Osts 10 Problem 3 Numerically integrate the 2nd order linear differential equation on the interval +5 + 4y - 0 v0-0 0-6 y(t) - 2e" - 2e-41 and compare it to the solution a) Plot the numerical solution and the true solution for y(t) (20 pts) b) Plot the numerical solution and the true solution for dy/dt (10 pts)
USING MATLAB Please post code 1. Solve the 2nd order differential equation ?+89 +15y-sin(t), y(0)-1,?(0)-2 symbolically and numerically, and plot both results together over the time interval 0,10 sec. Provide appropriate labels on both axes, a title, and a legend that denotes each solution. Check your symbolic answer by using the Matlab DIFF function to compute the appropriate derivatives and then substituting them into the differential equation.
Write a MATLAB code to solve below 2nd order linear ordinary differential equation by finite difference method: y"-y'-0 in domain (-1, 1) with boundary condition y(x-1)--1 and y(x-1)-1. with boundary condition y an Use 2nd order approximation, i.e. O(dx2), and dx-0.05 to obtain numerical solution. Then plot the numerical solution as scattered markers together wi exp(2)-explx+1) as a continuous curve. Please add legend in your plot th the analytical solution y-1+ Write a MATLAB code to solve below 2nd order...
Differential Equations with MATLAB/Plotting first order differential equations in Matlab/ Differential Equations MATLAB/IVP Matlab/IVP I'd really appreciate if I can get some help plotting these 3 first order differential equations as well as their comments. PLEASE! ANYTHING HELPS, I am very stuck :( EZplot and ODE 45 were mentioned in class and the instructions in class were not clear at all. Given the first order differential equation with initial condition. dy/dt = y t, y(0)=-1 Complete problems 1-3 in one...
using matlab solve numerically dy/dt = sin t, y(0)=0 for 0<=t<=4π the exact solution is y(t) = 1 - cos t. Compare the exact and numerical solution.
Solve two different first order differential equations (one linear and one non-linear) both analytically and numerically and compare the results in tabular and graphical forms. Include at least two different numerical solution techniques for each differential equation analyzed.
Problem #3: The Ralston method is a second-order method that can be used to solve an initial-value, first-order ordinary differential equation. The algorithm is given below: 2 Yi+1 = yi + k +k2)h Where kı = f(ti,y;) 3 k2 = ft;+ -h, y; +-kih You are asked to do the following: 3.1 Following that given in Inclass activity #10a, develop a MATLAB function to implement the algorithm for any given function, the time span, and the initial value. 3.2 Use...
Matlab Code for these please. 4. Using inbuilt function in MATLAB, solve the differential equations: dx --t2 dt subject to the condition (01 integrated from0 tot 2. Compare the obtained numerical solution with exact solution 5. Lotka-Volterra predator prey model in the form of system of differential equations is as follows: dry dt dy dt where r denotes the number of prey, y refer to the number of predators, a defines the growth rate of prey population, B defines the...
Problem Thre: 125 points) Consider the following initial value problem: dy-2y+ t The y(0) -1 ea dt ical solution of the differential equation is: y(O)(2-2t+3e-2+1)y fr exoc the differential equation numerically over the interval 0 s i s 2.0 and a step size h At 0.5.A Apply the following Runge-Kutta methods for each of the step. (show your calculations) i. [0.0 0.5: Euler method ii. [0.5 1.0]: Heun method. ii. [1.0 1.5): Midpoint method. iv. [1.5 2.0): 4h RK method...
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...