www.pudn.com > fredholm.rar > fredholm.m, change:2009-12-01,size:1093b


n=input('enter the number of divides:  '); %输入等分数目 
a=0;%下限 
b=1;%上线 
h=(b-a)/n;%间隔 
app=zeros(2*n+1,2*n+1); %系数矩阵 
v=zeros(1,2*n+1);%已知的函数值矩阵 
fre=zeros(1,2*n+1);%求出的fredholm 
rea=zeros(1,2*n+1);%求真值 
delt=zeros(1,2*n+1);%求差值 
fre=fre'; 
      %%%%%求复化simpson系数矩阵 
for i=1:2*n+1 
    for k=1:n 
        app(i,2*k)=(4/6)*h*exp((h/2)*(i-1)+(h/2)*(2*k-1)); 
    end 
end 
for i=1:2*n+1 
    for k=1:n-1 
        app(i,(2*k+1))=(2/6)*h*exp((h/2)*(i-1)+(h/2)*(2*k)); 
    end 
end 
for i=1:2*n+1 
    app(i,1)=(h/6)*exp((h/2)*(i-1)); 
    app(i,2*n+1)=(h/6)*exp((h/2)*(i-1)+1); 
end 
       %%%%%求已知的函数值 
for i=1:2*n+1 
    v(i)=(3/2)*exp((h/2)*(i-1))-(1/2)*exp((h/2)*(i-1)+2); 
end 
v=v'; 
      %%%%%用复化simpson求fredholm 
fre=inv(eye(2*n+1,2*n+1)-app)*v; 
      %%%%%求真值 
for i=1:2*n+1 
    rea(i)=exp((h/2)*(i-1));  
end 
rea=rea'; 
      %%%%%求差值 
for i=1:2*n+1 
    delt(i)=fre(i)-rea(i);  
end  
delt=delt'; 
x=[0:h/2:1]; 
zer=zeros(1,2*n+1); 
plot(x,fre,'x',x,rea,'.',x,delt,'.',x,zer,'--'); 
h=legend('复化值','真实值','差值','0值');