secd vs sec

7 次查看(过去 30 天)
David C
David C 2012-5-11
x=-89.5:0.001:89.5; y=1./secd(x); trapz(x,y) Gives 114
AND
x=-pi/2:0.001:pi/2; y=1./sec(x); trapz(x,y) Gives 2
Why?

采纳的回答

Geoff
Geoff 2012-5-11
Because your data ranges are different.
The area underneath the curve spanning -89.5:0.001:89.5 is approximately 180/pi times larger than the area underneath the curve spanning -pi/2:0.001:pi/2.
Your answers are correct, except you are using two different ranges. Surely the comparable range in degrees is -90:0.001:90
Note also that the step size for your degrees makes that calculation much more accurate than your radians range (which is using the same step size).
[edit] Compare apples with apples...
xd = -90:0.001:90;
yd = 1./secd(xd);
xr = xd * pi / 180;
yr = 1./sec(xr);
% Use radians for x-axis in both calculations
zd = trapz(xr, yd)
zr = trapz(xr, yr)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by