求教梯形求解积分
计算数值积分问题程序如下:
x=0:pi/100:2*pi;
y=sqrt(1+diff(sin(x+x.*sin(x))).^2);
trapz(x,y)
运行提示如下:
??? Error using ==> trapz
LENGTH(X) must equal the length of the first non-singleton dimension of Y.
检查在使用diff()后,矩阵长度会小1
这种情况怎么办?
PS:怎么用梯形法求解如下数值问题:
计算上平面曲线y=sin(x+xsin(x))的长度 x=0:pi/100:2*pi;
y=sqrt(1+diff(sin(x+x.*sin(x))).^2);
x=pi/200:pi/100:2*pi-pi/200;
trapz(x,y)
页:
[1]