How do I plot values taken from a for loop function?
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!