请问这段MATLAB代码有什么问题? 积分后还是原式
symst;symsa;a=5;int(exp(-0.4*(a*cos(t)+(25-a^2*(sin(t))^2)^0.5)),t,0,2*pi)...
syms t;syms a;a=5;int(exp(-0.4*(a*cos(t)+(25-a^2*(sin(t))^2)^0.5)),t,0,2*pi)
展开
1个回答
展开全部
syms t;
syms a;
a=5;
int(exp(-0.4*(a*cos(t)+(25-a^2*(sin(t)).^2).^0.5)),t,0,2*pi)
Warning: Explicit integral could not be found.
找不到显式积分的解,所以建议用数值积分quad求解
syms t;
syms a;
a=5;
y=quad(@(t)exp(-0.4*(a*cos(t)+(25-a.^2*(sin(t)).^2).^0.5)),0,2*pi)
y =
3.6784
syms a;
a=5;
int(exp(-0.4*(a*cos(t)+(25-a^2*(sin(t)).^2).^0.5)),t,0,2*pi)
Warning: Explicit integral could not be found.
找不到显式积分的解,所以建议用数值积分quad求解
syms t;
syms a;
a=5;
y=quad(@(t)exp(-0.4*(a*cos(t)+(25-a.^2*(sin(t)).^2).^0.5)),0,2*pi)
y =
3.6784
追问
大神帮忙看看,这个代码还有什么问题?
r=5;
a=0.4;
x=-5:0.1:5;
y=-5:0.1:5;
[X,Y]=meshgrid(x,y);
syms t;
Z=quad(@(t)exp(-(sqrt(X.^2+Y.^2)*cos(t)+(r^2-(X.^2+Y.^2)*(sin(t))^2).^0.5)*a),0,2*pi);
surf(X,Y,Z)
shading flat
追答
r=5;
a=0.4;
x=-5:0.1:5;
y=-5:0.1:5;
[X,Y]=meshgrid(x,y);
syms t;
for i=1:length(X)
for j=1:length(Y)
Z(i,j)=quad(@(t)exp(-(sqrt(X(i,j).^2+Y(i,j).^2).*cos(t)+(r^2-(X(i,j).^2+Y(i,j).^2).*(sin(t)).^2).^0.5)*a),0,2*pi);
end
end
Z1=real(Z);
surf(X,Y,Z1)
shading flat
你这个得用循环实现每个点积分的计算,否则矩阵维度不相等
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询