Effacer les filtres
Effacer les filtres

secd vs sec

1 vue (au cours des 30 derniers jours)
David C
David C le 11 Mai 2012
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?

Réponse acceptée

Geoff
Geoff le 11 Mai 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)

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by