フィルターのクリア

I need help computing the pressure gradient at point “i”, using a centered finite difference using a for loop.

1 回表示 (過去 30 日間)
Matthew
Matthew 2023 年 10 月 9 日
移動済み: Torsten 2023 年 10 月 10 日
Here is the formula I need to code. I have the code for both p and x but I'm not sure how to compute this formula using the variable i in a for loop. Can I use a matrix that is more than 2x2 or does it have to be 1x'somegivennumber'? Here is the code I have:
x1 = [1e6:20000:5e6];
z = [0:50:10000];
L = 4e6; % in m
D_c = 5000;% in m
D1 = [0:25:5000];
x_o = 1e6; % in m
x_2 = [x_o:20000:5e6];
[x2,D2] = meshgrid(x1,D1); % x2 is the other x values I want to use for x in the bottom of the formula
[x3,z1] = meshgrid(x,z);
Tw_o = 300; % in K
LR_w = 0.004; % in K/m
LR_c = -0.007; % in K/m
pz_0 = 1000; % in mb
D = D_c.*(sin((pi/L).*(x2-x_o)));
T_c = Tw_o-(((LR_w-LR_c).*D)-((LR_c.*D2)));
T_w = Tw_o-((LR_w.*z1));
T_per = T_c-T_w;
g = 9.81;
Rd = 287;
p = pz_0*(((((T_c)-(LR_c.*D2))./(T_c))).^((g)/(Rd*LR_c))); % this array is what I want to use for p in the formula
  1 件のコメント
Matthew
Matthew 2023 年 10 月 9 日
Basically I want to do this for all elements in p and x2:
((p(1:1)-p(2:1))/(x2(1:1)-x2(1:2)))

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

回答 (1 件)

Torsten
Torsten 2023 年 10 月 10 日
移動済み: Torsten 2023 年 10 月 10 日

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by