Error in for loop calculation

1 次查看(过去 30 天)
Hi, I am getting 0 as answer though the answers cannot be zero. If some one can guide
temperature = 212 ; % temperature in deg F
oilapi = 41 ; % oil API
gamma = (0.00091 * temperature) - (0.0125*oilapi);
gasg = 0.65 ;
U(100)= 100;
for P = 101:2000
U(P) = gasg * U(P-1); %/ (18 * (10 ^ (gamma)))^1.205);
end
U

采纳的回答

Stephen23
Stephen23 2021-3-30
编辑:Stephen23 2021-3-30
You are confusing data with indices. Do not use data as indices.
temperature = 212 ; % temperature in deg F
oilapi = 41 ; % oil API
gamma = (0.00091 * temperature) - (0.0125*oilapi);
gasg = 0.65 ;
P = 100:2000; % data!
U = P; % data!
for k = 2:numel(U) % indices!
U(k) = gasg * U(k-1); %/ (18 * (10 ^ (gamma)))^1.205);
end
U
U = 1×1901
100.0000 65.0000 42.2500 27.4625 17.8506 11.6029 7.5419 4.9022 3.1864 2.0712 1.3463 0.8751 0.5688 0.3697 0.2403 0.1562 0.1015 0.0660 0.0429 0.0279 0.0181 0.0118 0.0077 0.0050 0.0032 0.0021 0.0014 0.0009 0.0006 0.0004

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Gamma Functions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by