Why does the correctairspeed function use a different formula than the formula given in the documentation?

2 views (last 30 days)
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 Comments
John D'Errico
John D'Errico on 8 Mar 2020
Edited: John D'Errico on 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.
Sam
Sam on 8 Mar 2020
Edited: Sam on 8 Mar 2020
Ah, yes that might've been unclear from my example. I did look at the numbers, but I thought the above example would illustrate it more clearly. The values differ about 5% in the above example. However, this difference increases more and more with increasing altitude. At an altitude of 10,000 m, say, the difference is more than 40%. I can see how this happens, because the formula - as opposed to the correctairspeed function - doesn't include any altitude effects; only MSL values are used. Therefore, the effects of decreasing air density and pressure with altitude aren't "seen" in the calculation of the CAS. However, reading the docs, it seems to be pointed out very explicitly that MSL values should be used.

Sign in to comment.

Answers (0)

Categories

Find more on Aerospace Applications in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!