I I wrote a command but for some reason it only prints the enthalpy value of water

1 次查看(过去 30 天)
R = 8.314; % Ideal Gas Constant
T = 300 : 50 : 1000; % Temperature range from 300 K to 1000 K with increments of 50
% Create Temperature Loop
I = 0; % Initialization of loop variable
for T = 300 : 50 : 1000; % Temperature range from 300 K to 1200 K with increments of 50
I = I + 1; % Loop variable
% Hydrogen enthalpy calculations
hf_h = 0; % Hydrogen enthalpy at the standard state
hs_h = R*(((3.057 * T) + ((1/2) * 2.677E-3 * T^2) - ((1/3) * 5.810E-6 * T^3) + ((1/4) * 5.521E-9 * T^4) - ((1/5) * 1.812E-12 * T^5)) - (3.057 * 298 + ((1/2) * 2.677E-3 * 298^2) - ((1/3) * 5.810E-6 * 298^3) + ((1/4) * 5.521E-9 * 298^4) - ((1/5) * 1.812E-12 * 298^5)));
H_hydrogen = (hf_h + hs_h); % Enthalpy of Hydrogen
% Oxygen enthalpy calculations
hf_o = 0; % Oxygen enthalpy at the standard state
hs_o = R * (((3.626 * T) - ((1/2) * 1.878E-3 * T^2) + ((1/3) * 7.055E-6 * T^3) - ((1/4) * 6.764E-9 * T^4) + ((1/5) * 2.156E-12 * T^5)) - (3.626 * 298 - ((1/2) * 1.878E-3 * 298^2) + ((1/3) * 7.055E-6 * 298^3) - ((1/4) * 6.764E-9 * 298^4) + ((1/5) * 2.156E-12 * 298^5)));
H_oxygen = (hf_o + hs_o); % Enthalpy of Oxygen
% Water enthalpy calculations
hf_w = -241820; % Water enthalpy at the standard state
hs_w = R * (((4.070 * T) - ((1/2) * 1.108E-3 * T^2) + ((1/3) * 4.152E-6 * T^3) - ((1/4) * 2.964E-9 * T^4) + ((1/5) * 0.807E-12 * T^5)) - (4.070 * 298) - ((1/2) * 1.108E-3 * 298^2) + ((1/3) * 4.152E-6 * 298^3) - ((1/4) * 2.964E-9 * 298^4) + ((1/5) * 0.807E-12 * 298^5));
H_water = (hf_w + hs_w) % Enthalpy of Water
% Create new variables to save the new calculated values for hydrogen, oxygen, and water enthalpy at each temperature increment
Hydrogen_Enthalpy(I) = H_hydrogen;
Oxygen_Enthalpy(I) = H_oxygen;
Water_Enthalpy(I) = H_water;
Temperature(I) = T;
end % End Loop

回答(1 个)

VBBV
VBBV 2024-3-12
There is a missing semicolon in this line, which makes it to print for each iteration in for loop
H_water = (hf_w + hs_w); % a semicolon is missing in this line in for loop

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by