Finding a change in a variable due to a change in another variable

3 ビュー (過去 30 日間)
Anirban Mandal
Anirban Mandal 2021 年 11 月 11 日
コメント済み: Star Strider 2021 年 11 月 12 日
I want to write a code for finding potential temperature. There I want to fix temperature. And at that temperature level, I want to calculate potential temperature varying the pressure. Then for different temperatures, I want to repeat the process. For more info about potential temperature, check this-Potential temperature. But the problem with temperature is that I can't just pick any arbitrary interval or change in temperature value. In atmosphere, there is a term called lapse rate. There temperature changes in a certain manner, i.e 6.5K/100hPa. I want to implement this change in my temperature range, How can I do this? I have chosen 300K as the base temperature and 1010hPa as base pressure.
p=200:1000;
t=210:305;
for i=1:length(t)
for j=1:length(p)
theta(i,j)=t(i)*((1000/p(j))^0.286);
end
end
figure
contourf(t,p,theta')
set(gca,'YDir','reverse')
  2 件のコメント
Jan
Jan 2021 年 11 月 11 日
Remember that for Matlab and the readers the values are just number. Therefor the term "temperatur" is confusing only.
Find the formula you want to implement. Afterwards this is a question concerning Matlab. Currently you did not explain, what you want to impelement, only that it is something.
Anirban Mandal
Anirban Mandal 2021 年 11 月 12 日
I have explained above what I want to do. If you go throught the code you can understand my intention.

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

採用された回答

Star Strider
Star Strider 2021 年 11 月 11 日
編集済み: Star Strider 2021 年 11 月 11 日
See if the griddedInterpolant function will produce the desired result
p=200:1000;
t=210:305;
[P,T] = ndgrid(p,t);
Z = T.*((1000./P).^0.286);
PT = griddedInterpolant(P,T,Z);
P760_T273 = PT(760,273) % Potential Temperature At P=760 & T=273
P760_T273 = 295.2908
EDIT — (11 Nov 2021 at 13:04)
An anonymous function would also work —
PTfcn = @(P,T) T.*((1000./P).^0.286);
P760_T273f = PTfcn(760,273)
P760_T273f = 295.2908
.
  2 件のコメント
Anirban Mandal
Anirban Mandal 2021 年 11 月 12 日
Thanks. I figured out another way though. Since temperature is decreasing in a certain way, I initiated a loop where I defined the decrease in temperature. Then I used those temperature values in the next loops for calculating theta.
Star Strider
Star Strider 2021 年 11 月 12 日
As always, my pleasure!
I admit that I was not absolutely certain what the desired result was. (A similar relation, important in aviation, is Density altitude.)
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by