clear all
close all
%function to be solved
a=2;
f = @(x,y) 2.*y.*(y.^2-1).*(2+y);
yy=linspace(-2.1,1.1);
figure(1)
plot(yy,f(0,yy))
title('f(y) vs. y plot for a=2')
xlabel('y')
ylabel('f(y)')
x_ini=0;
x_end=10;
%Plotting Direction field
figure(2)
dirrfield(f,0:1:10,-3:.5:3)
hold on
%plot for different initial velocity
for v0=-10:1:10
[xs,ys] = ode45(f,[x_ini,x_end],v0);
plot(xs,ys,'b','Linewidth',2)
end
hold off
title('phase potrait plot for a=2')
xlabel('x')
ylabel('y(x)')
grid on
figure(3)
[xs,ys] = ode45(f,[x_ini,1],-5);
plot(xs,ys,'b','Linewidth',2)
title('y(x) vs. x plot for a=2 and y(0)=-5')
xlabel('x')
ylabel('y(x)')
grid on
%function to be solved
a=4;
f = @(x,y) 4.*y.*(y.^2-1).*(2+y);
yy=linspace(-2.1,1.1);
x_ini=0;
x_end=10;
%Plotting Direction field
figure(4)
dirrfield(f,0:1:10,-3:.5:3)
hold on
%plot for different initial velocity
for v0=-10:1:10
[xs,ys] = ode45(f,[x_ini,x_end],v0);
plot(xs,ys,'b','Linewidth',2)
end
hold off
title('phase potrait plot for a=4')
xlabel('x')
ylabel('y(x)')
grid on
figure(5)
[xs,ys] = ode45(f,[x_ini,1],-5);
plot(xs,ys,'b','Linewidth',2)
title('y(x) vs. x plot for a=4 and y(0)=-5')
xlabel('x')
ylabel('y(x)')
grid on
%%Matlab function for direction filed
function dirrfield(f,tval,yval)
% dirfield(f, t1:dt:t2, y1:dy:y2)
% plot direction field for first order ODE y' =
f(t,y)
% using t-values from t1 to t2 with spacing of dt
% using y-values from y1 to t2 with spacing of d
% f is an @ function, or an inline function,
% or the name of an m-file with
quotes.
% Example: y' = -y^2 + t
% Show direction field for t in [-1,3], y in [-2,2],
use
% spacing of .2 for both t and y:
% f = @(t,y) -y^2+t
% dirfield(f, -1:.2:3, -2:.2:2)
[tm,ym]=meshgrid(tval,yval);
dt = tval(2) - tval(1);
dy = yval(2) - yval(1);
fv = vectorize(f);
if isa(f,'function_handle')
fv = eval(fv);
end
yp=feval(fv,tm,ym);
s = 1./max(1/dt,abs(yp)./dy)*0.75;
h = ishold;
quiver(tval,yval,s,s.*yp,0,'r'); hold on;
%quiver(tval,yval,-s,-s.*yp,0,'r');
if h
hold on
else
hold off
end
axis([tval(1)-dt/2,tval(end)+dt/2,yval(1)-dy/2,yval(end)+dy/2])
end
%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%
solve in matlab please Draw the phase line for ay-ay(y2-1)(2+y), α > 0 and then using Matlab Problem 1 : graph the solution for different initial conditions. Once you complete that, double the...
MATLAB HELP 3. (a) In one window, graph four different solutions to y 00 + 10y 0 + y = sin t by using different initial conditions. (Be sure that all four graphs are clearly visible in the window.) (b) Describe the apparent behavior of the solutions as t → ∞. 4. (a) Graph solutions to y 00 + a y = sin 3t, y(0) = 1, y 0 (0) = 1 for each of the values a = 9.5,...
solve it with matlab 25.24 Given the initial conditions, y(0) = 1 and y'(0) = 1 and y'(0) = 0, solve the following initial-value problem from t = 0 to 4: dy + 4y = 0 dt² Obtain your solutions with (a) Euler's method and (b) the fourth- order RK method. In both cases, use a step size of 0.125. Plot both solutions on the same graph along with the exact solution y = cos 2t.
Problem 3. Given the initial conditions, y(0) from t- 0 to 4: and y (0 0, solve the following initial-value problem d2 dt Obtain your solution with (a) Euler's method and (b) the fourth-order RK method. In both cases, use a step size of 0.1. Plot both solutions on the same graph along with the exact solution y- cos(3t). Note: show the hand calculations for t-0.1 and 0.2, for remaining work use the MATLAB files provided in the lectures Problem...
Please solve this in Matlab Consider the initial value problem dx -2x+y dt x(0) m, y(0) = = n. dy = -y dt 1. Draw a direction field for the system. 2. Determine the type of the equilibrium point at the origin 3. Use dsolve to solve the IVP in terms of mand n 4. Find all straight-line solutions 5. Plot the straight-line solutions together with the solutions with initial conditions (m, n) = (2, 1), (1,-2), 2,2), (-2,0)
please solve the initial-value problem only thanks 2. Now find the explicit solution for the initial-value problem = y(ay - 1), y(0) = 1, by treating it as a Berno equation, and provide a graph of the solution function using Plot[y[x].(x,0,1}]. dz
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.
Complete using MatLab 1. Consider the following initial value problem 3t2-y, y(0) = 1 Using Euler's Method and the second order Runge-Kutta method, for t E [0, 1] with a step size of h 0.05, approximate the solution to the initial value problem. Plot the true solution and the approximate solutions on the same figure. Be sure to label your axis and include an a. appropriate legend b. Verify that the analytic solution to the differential equation is given by...
Solve the initial value problem 2yy'+3=y2+3x with y(0)=4a. To solve this, we should use the substitution u=With this substitution,y=y'=uEnter derivatives using prime notation (e.g., you would enter y' for dy/dx ).b. After the substitution from the previous part, we obtain the following linear differential equation in x, u, u'c. The solution to the original initial value problem is described by the following equation in x, y.
I. Use Euler's method with step size h = 0.1 to numerically solve the initial value problem y,--2ty+y2, y(0) 1 on the interval 0 < t 2. Compare your approximations with the exact solution. I. Use Euler's method with step size h = 0.1 to numerically solve the initial value problem y,--2ty+y2, y(0) 1 on the interval 0
Solve the given symbolic initial value problem and sketch a graph of the solution y" + 2y =60(1-4): y0)=0, y(0) = 2 Solve the given symbolic initial value problem. y(t) =