我想找到元素(x)和元素(x + 1)之间数组的平均值
for val = 1: xMid_p-1
eapDia_p = diaArray_p(1,val);
baseDia_p = diaArray_p(1,end);
curDiaArray_p = linspace(eapDia_p, baseDia_p, xMid_p-1);
curRadArray_p = curDiaArray_p/2;
maxRad = max(curRadArray_p);
for val = 1 : xMid_p-1
ln(1,val) = maxRad(:) - curRadArray_p(val);
lnE(1,val) = ln(1,val).^3;
presAn(1,val)= acos(((refDia_p/2)*cos(refPresAng_p))./curRadArray_p(val));
arcToo(1,val) = 2 * curRadArray_p(val)*((twRefDia_p/refDia_p)+(tan(refPresAng_p)-refPresAng_p)-(tan(presAn(1,val))-presAn(1,val)));
chor(1,val) = 2 * curRadArray_p(val) * sin(arcToo(1,val)/(curRadArray_p(1,val)*2));
for val = 1 : xMid_p - 2
lnM(1,val) = maxRad(:) - curRadArray_p(val);
lnME(1,val)=lnM(1,val).^3;
end
end
lnCubed(1,:) = ln.^3;
lnMCubed(1,:) = lnM.^3;
lnEq = lnCubed(2:end) - lnMCubed;
end
请参阅chor(1,val),这将给出值:
chor =
1 2 3 4 5 6 7 8
我想找到平均chor,因此数组将是一个较小的元素并将给出结果
aveChor =
1.5 2.5 3.5 4.5 5.5 6.5 7.5
答案 0 :(得分:1)
使用indexing
-
aveChor = (chor(2:end) + [chor(1:end-1)])/2
使用diff
-
aveChor = (2*chor(1:end-1) + diff(chor))/2