secd vs sec
3 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Geoff
on 11 May 2012
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 Comments
More Answers (0)
See Also
Categories
Find more on Special Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!