Borrar filtros
Borrar filtros

Code for boundary value problem

1 visualización (últimos 30 días)
Ollie
Ollie el 12 de Oct. de 2015
I'm trying to answer this question:
This is the code I have produced:
function [x,y] = bvp(coeff, bcs, xspan, h)
N = (xspan(2)-xspan(1))/(h);
x = xspan(1):h:xspan(2);
main = [ones(N-1,1).*(coeff(3)*h^2-2*coeff(1))];
sub = ones(N-2,1).*(coeff(1)-coeff(2)*h/2);
super = ones(N-2,1).*(coeff(1)+coeff(2)*h/2);
A = (diag(main) + diag(sub,-1) + diag(super,1));
B = [(-(coeff(1)-coeff(2)*h/2)*bcs(1));zeros(N-3,1);-(coeff(1)+coeff(2)*h/2)*bcs(2)];
y = A\B;
y = [bcs(1); y; bcs(2)];
end
I'm not sure why this is not working. Any help would be appreciated.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by