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

3 ビュー (過去 30 日間)
Mutahar
Mutahar 2023 年 1 月 29 日
編集済み: Mutahar 2023 年 1 月 29 日
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.

回答 (1 件)

KSSV
KSSV 2023 年 1 月 29 日
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 件のコメント
Mutahar
Mutahar 2023 年 1 月 29 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by