Why does the correctairspeed function use a different formula than the formula given in the documentation?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm using the MATLAB aerospace toolbox, amongst others to calculate the calibrated airspeed from the true airspeed. For this, I use the MATLAB function correctairspeed. In the documentation, it says to input an (array of) airspeed(s), speed(s) of sound, and static pressure(s) as the first three arguments. These are not necessarily mean sea-level (MSL) values. Then, looking at the Calibrated Airspeed implementation/formula on this page, I see a different implementation of the Calibrated Airspeed. Here, the MSL air density and pressure are used.
The discrepancy between the two is confirmed when comparing the two methods (1. using the formula, 2. using the correctairspeed function). Note that the equality check in the code below is only illustrative: I did actually check the numbers and they're quite off.
V = 100;
[T0, a0, p0, rho0] = atmosisa(0);
[T, a, p, rho] = atmosisa(1000);
% This gives the correct value of the CAS at an altitude of 1000 meter
CASfunction = correctairspeed(V, a, p, 'TAS', 'CAS', 'Equation');
% This doesn't
CASformula = sqrt((2 * 1.4 * p0)/((1.4-1) * rho0) * ((1/2 * rho0 * V ^2 / p0 + 1) ^((1.4 - 1)/1.4) - 1));
% Meaning that the two outcomes aren't equal.
CASfunction == CASformula
ans =
logical
0
% Changing p0 to p at 1000 m doesn't help
CASformula = sqrt((2 * 1.4 * p)/((1.4-1) * rho0) * ((1/2 * rho0 * V ^2 / p + 1) ^((1.4 - 1)/1.4) - 1));
CASfunction == CASformula
ans =
logical
0
% And changing rho0 to rho at 1000 m doesn't either
CASformula = sqrt((2 * 1.4 * p0)/((1.4-1) * rho) * ((1/2 * rho * V ^2 / p0 + 1) ^((1.4 - 1)/1.4) - 1));
CASfunction == CASformula
ans =
logical
0
Even when trying changing each of the p0 and rho0 to non-MSL values p and rho, individually, I don't get the right values.
I would like to have the anlayitcal formula underlying correctairspeed because I want to determine the formula for the time derivative of the CAS. Now my question is, whether the analytical formula that is actually used for the calibrated airspeed in the correctairspeed is documented somewhere. I only need the formula for subsonic velocities.
Thanks in advance.
2 commentaires
John D'Errico
le 8 Mar 2020
Modifié(e) : John D'Errico
le 8 Mar 2020
You have tested that they are not idetically equal. However, what is the DIFFERENCE between the results? I cannot test your example, since I don't have that toolbox (as must be true for most people). So unless you show tha actual results, we cannot even guess i]f the difference is 1e-17, or something in the least significant bits of the numbers.
NEVER test for EXACT equality between two floating point numbers. Look instead at the difference.
Réponses (0)
Voir également
Catégories
En savoir plus sur Aerospace Applications 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!