Matlab 数值积分
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 18:44:39
Matlab 数值积分
i=2;
q=acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i));
f=@(x)((x.^2-1).*x.^2.*i*sin(q)-x.^2.*i^2*asin(x.*sin(q))+(x.^2.*i^2-(x.^2-1).^2).*q)./(pi*(x.^2-1).^2)+1;
f2=quad(f,1/(i+1),1/(i-1));
Error using ==> mtimes
Inner matrix dimensions must agree.
错在哪呀.
i=2;
q=acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i));
f=@(x)((x.^2-1).*x.^2.*i*sin(q)-x.^2.*i^2*asin(x.*sin(q))+(x.^2.*i^2-(x.^2-1).^2).*q)./(pi*(x.^2-1).^2)+1;
f2=quad(f,1/(i+1),1/(i-1));
Error using ==> mtimes
Inner matrix dimensions must agree.
错在哪呀.
matlab不会把q=acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i)); 代入f的
改为下面的即可i=2;
f=@(x)((x.^2-1).*x.^2.*i.*sin(acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i)))-x.^2.*i^2.*asin(x.*sin(acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i))))+(x.^2.*i^2-(x.^2-1).^2).*acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i)))./(pi*(x.^2-1).^2)+1;
f2=quad(f,1/(i+1),1/(i-1))
f2 =
0.5959
再问: 为什么 i 后面也要加点呢,跪求指教
再答: 加点是为了向量运算。
改为下面的即可i=2;
f=@(x)((x.^2-1).*x.^2.*i.*sin(acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i)))-x.^2.*i^2.*asin(x.*sin(acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i))))+(x.^2.*i^2-(x.^2-1).^2).*acos((x.^2-1+x.^2.*i^2)./(2*x.^2.*i)))./(pi*(x.^2-1).^2)+1;
f2=quad(f,1/(i+1),1/(i-1))
f2 =
0.5959
再问: 为什么 i 后面也要加点呢,跪求指教
再答: 加点是为了向量运算。