How I plot approximate solution of a boundary value problem using my below code ?

I have tried to plot the approximate solution for boundary value problem using my below code such that I have tried ezplot command but dosn't work .approximate solution that I have got are : -1.33,-1.1660,-1.3320
**Code **
N=4;
n=N-1;
a=-1;b=1;h=(b-a)/N ;
x=linspace(a,b,N+1);
x=x(2:end-1);
A=diag(ones(n,1));
B=diag(ones(n-1,1),-1);
C=diag(ones(n-1,1),1);
K1=1/h*(2*A-B-C);
K2=h*(4*A+B+C)
K=K1+K2;
K(1,1)=K(2,2)/2;
K(n,n)=K(1,1);
f=@(x) (-4*x^2-6)*exp(x^2);
b=zeros(n,1);
for i=1:n
b(i)=h*f(x(i));
end
b(1)=h/2*f(x(1));
b(n)=h/2*f(x(n));
U=pinv(K)*b

Réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Produits

Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by