splelvis 发表于 2010-2-25 08:55

求助,逼近积分

u''(x)=f(x),
边界boundary conditions u(a)=0,u(b)=0.
(u(x+h)-2u(x)+u(x-h))/h^2=f(x);

maltab code:

clear all
a=0;
b=1;
n=10;
h=(b-a)/(n+1);
x_with_boundary=linspace(a,b,n+2)';
x=x_with_boundary(2:n+1);
A=h^(-2).*(diag(ones(1,n-1),-1)+diag(-2.*ones(1,n),0)+diag(ones(1,n-1),1));
rhs=f4(x);
sol=A\rhs;
sol_with_boundary_conds=;
plot(x_with_boundary,sol_with_boundary_conds);


另开一文档,f4,
function y=f4(x)
y=ones(length(x),1);

出来后是抛物线。


现在问题是,
u''(x)=sin(2pix);
u(-1)=0;
u(1)=0;
范围[-1;1]

请问各位要怎么把问题代入原题目中,哪些数值需要修改。

splelvis 发表于 2010-2-26 04:07

没人能帮忙一下吗,
还是有什么资料不明确?
页: [1]
查看完整版本: 求助,逼近积分