I need help computing the pressure gradient at point “i”, using a centered finite difference using a for loop.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1506794/image.png)
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
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!