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

조회 수: 4 (최근 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 CenterFile Exchange에서 Thermal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by