matlab中带参数的定积分求解
2017-05-02
来个简单点的。
步长统一取0.01
代码如下:
>> clear
phi=[0:0.01:pi]';
r=sqrt(1.16-0.8*cos(phi));
beta=[-2:0.01:2]';
%计算矩阵K
for i=1:length(r)
for j=1:length(beta)
K(i,j)=sqrt(4*r(i)/((1+r(i))^2+beta(j)^2));
end
end
%计算被积函数,进而求出矩阵F(K)和E(K):
theta=0:0.01:pi/2;
for i=1:length(r)
for j=1:length(beta)
for k=1:length(theta)
f(i,j,k)=1./sqrt(1-K(i,j)^2*sin(theta(k)^2));
e(i,j,k)=sqrt(1-K(i,j)^2*sin(theta(k)^2));
end
end
end
%计算矩阵F(K)和E(K),以及M的被积函数m
for i=1:length(r)
for j=1:length(beta)
F(i,j)=sum(f(i,j,[1:length(theta)]))*0.01;
E(i,j)=sum(e(i,j,[1:length(theta)]))*0.01;
m(i,j)=(1-0.4*cos(phi(i)))/(K(i,j)*sqrt(r(i)^3))*(1-K(i,j)^2/2)*(F(i,j)-E(i,j));
end
end
%计算向量M
for j=1:length(beta)
M(j)=sum(m([1:length(r),j]))*0.01;
end
%作图
plot(beta,M)
计算结果见上传的文档
2024-10-13 广告