Error in for loop calculation
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Stephen23
le 30 Mar 2021
Modifié(e) : Stephen23
le 30 Mar 2021
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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!