How do I plot values taken from a for loop function?

4 views (last 30 days)
Hi, I want to plot altitude (a) vs Temperature (T) but the Temperature is a function of altitude. Please find conditions below:
clear
clc
B0=-0.00356616 %Lapse Rate
T0=518.67
B1=0
T1=389.97
B2=0.00054864
T2=389.97
for a=0 %Altutude in ft
B=B0 %Lapse Rate
T=T0 %Temperature in Rankine
for a=0.1:36089.2 %Altutude in ft
B=B0 %Lapse Rate
T=T0*(1+(B0/T0)*a) %Temperature in Rankine
for a=36089.2:65616.8 %Altutude in ft
B=B1 %Lapse Rate
T=T1*(1+(B1/T1)*a) %Temperature in Rankine
for a=65616.8:104987 %Altutude in ft
B=B2 %Lapse Rate
T=T2+((a-a2)*B2) %Temperature in Rankine
end
end
end
end
plot(T,a)
Essentially I am trying to create a plot for altitude (a) is on the y-axis and Temperature (T) is on the x-axis. The value of T will change as altitude increases all the way to the maximum altitude value of 36089.2. Please advice how I am supposed to write the code.

Answers (1)

KSSV
KSSV on 29 Jan 2023
clc
B0=-0.00356616 ; %Lapse Rate
T0=518.67 ;
B=B0 ; %Lapse Rate
a=0.1:36089.2 ; %Altutude in ft
T=T0*(1+(B0/T0)*a) ; %Temperature in Rankine
plot(T,a)
  1 Comment
Mutahar
Mutahar on 29 Jan 2023
Thank you for your response; would you please be able to advise further. How would I do it if the conditions continue? For example:
B1=0
T1=389.97
B2=0.00054864
T2=389.97
for a=[36089.2:65616.8] %Altutude in ft
B=B1 %Lapse Rate
T=T1*(1+(B1/T1)*a) %Temperature in Rankine
for a=[65616.8:104987] %Altutude in ft
B=B2 %Lapse Rate
T=T2+((a-a2)*B2) %Temperature in Rankine
And then I want to plot all values of Altitude (a) vs Temperature (T) on one plot from 0 to 104987.

Sign in to comment.

Categories

Find more on Thermal Analysis 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!