MATLAB CODE REQUIRED
Consider the problem of estimating y(0.5) for the boundary-value
problem
y''+ y' = y + 2, y(0) = 0, y'(1) = 2. Find the solution using 2
approaches:
(b) Use finite difference with n = 10.Please provide Matlab code. What is y(0.5) value with Matlab?
(c) Using bvp4c. Please provide Matlab code. What is y(0.5) value with Matlab?
b) Using Finite Diference Method :
function output = ode45function(t,y)
clc;
clear all;
close all;
time_period = [0 10];
intial = [0,2];
[t,y] =
ode45(@ode45function,time_period,initial);
plot (t,y(:,1));
figure
plot (t,y(:,2));
output = [y(0.5); -1*y(2)+y(1)+2];
c)Using bvp4c :
function output = output_bvp(x,y)
clc;
clear all;
close all;
init = bvpinit(linespace(1,3,10),[0,2])
sol = bvp4c(@bvp_output,init);
x = linespace (1,3,100);
BS=deval(sol,x);
plot(x,BS);
output=[y(0.5); -1*y(2)+y(1)+2];
Get Answers For Free
Most questions answered within 1 hours.