Trying to plot viscosity and kinematic viscosity vs altitude
Show older comments
close all
clear
clc
temp_sl = 288; %temperature at sea level
rho_sl = 1.225; %density at sea level
alt = 1:1:47000;
temp_alt = zeros(1,47000);
d = zeros(1,47000);
d_viscosity = zeros(1,47000);
k_viscosity = zeros(1,47000);
%temperature in Kelvin
for i = 1:47000
if alt(i) < 11000
temp_alt(i) = temp_sl - 0.0065*alt(i);
elseif alt(i) > 10999 && alt(i) < 25000
temp_alt(i) = 216.54;
else
temp_alt(i) = 191.5 + 0.001*alt(i);
end
end
%kinematic viscosity
for i = 1:47000
d_viscosity(i) = 2.287973*10^(-6) + 6.259793*(10^(-8))*temp_alt(i)-3.131956*(10^(-11))*temp_alt(i)^(2) + 8.15038*(10^(-11))*temp_alt(i)^(3);
d(i) = rho_sl*(temp_alt(i)/temp_sl).^(4.2588);
k_viscosity(i) = d_viscosity(i)/d(i);
end
%%%%%%%%%%%%%%%
plot(d_viscosity, alt, "DisplayName","Dynamic Viscosity")
hold on
plot(k_viscosity, alt, "DisplayName","Kinematic Viscosity")
hold off
4 Comments
temp_alt can't be a function handle
temp_alt = @(T_sl,h) (T_sl - 0.0065*h);
and an array
temp_alt(i) = temp_sl - 0.0065*m;
at the same time.
T_sl in the line
temp_alt(i) = 0.0028*m+((0.001*32000+(T_sl - 0.0065*11000-0.001*20000))-0.0028*32000);
is undefined.
temp_alt = zeros(1,47000);
instead of
temp_alt = zeros(1:47000);
Same for the other variables.
T undefined in
d_viscosity(i) = (2.287973*10^-6) + (6.259793*10^-8)*T(i) - (3.131956*10^11)*T(i)^2 + (8.15038*10^-11)*T(i)^3;
temp undefined in
d(i) = rho_sl*(temp(i)/temp_sl).^(4.2588);
And it's ok now ?
Roxanne Williamson
on 15 Feb 2022
William Rose
on 27 Feb 2022
Accepted Answer
More Answers (0)
Categories
Find more on Aerospace Applications 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!