フィルターのクリア

Error in for loop calculation

1 回表示 (過去 30 日間)
Avinav Kumar
Avinav Kumar 2021 年 3 月 30 日
編集済み: Stephen23 2021 年 3 月 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 Center および File ExchangeGamma Functions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by