各位大大门好
非常感谢上一篇在推文回答我的问题
经过尝试之后
发现经由trapz之后的值都会比较小,照下组数据应该算出来结果是要大于180
X轴data是:
x = 0 : 6 : 180;
Y轴data是:
y = [0, 1.55464981024354e-06, 5.83937700379266e-06, 1.23059070365907e-05,
2.04318517979475e-05, 2.97201993727277e-05, 3.97004137484849e-05,
4.99306499001924e-05, 6.00008482354052e-05, 6.95364018836329e-05,
7.82020677438476e-05, 8.57059548886770e-05, 9.18033097894118e-05,
9.62998878420099e-05, 9.90548056864478e-05, 9.99826536894291e-05,
9.90548056867048e-05, 9.62998878424930e-05, 9.18033097900734e-05,
8.57059548894716e-05, 7.82020677447207e-05, 6.95364018845333e-05,
6.00008482362841e-05, 4.99306499010090e-05, 3.97004137491947e-05,
2.97201993732905e-05, 2.04318517983462e-05, 1.23059070368372e-05,
5.83937700390511e-06, 1.55464981026809e-06, 0];
方法一: 基本土法炼钢
area = zeros(1,31)
for i = 1:30
area(1,i) = sqrt((y(i+1) - y(i))^2 + (x(i+1) - x(i))^2);
area(1,31) = area(1,31) + area(1,j);
end
算出曲线总长度答案是 area(1,31) = 1.800000000001348e+02;
方法二: 用interpl内插再使用trapz积分
曲线在上的弧长s=∫√(1+y'2 )dx
x = 0 : 6 : 180;
xi = 0 : 0.00001 : 180;
yi = interpl(x, y, xi, 'spline');
plot(x, y, 'o', xi, yi);
dy = diff(yi);
area1 = 0.00001*trapz((1+dy.^2).^0.5);
算出曲线总长度答案是 area1 = 1.7999999e+02;
不清楚哪边出了问题
希望有大大能解惑
谢谢