Hi Siti
To perform an iterative process where you update Tf until the difference between Tf and T_average is zero, you need to set up a loop that recalculates Tf and T_average in each iteration.
Below is the modified version of your code:
Tf = 140 ; %Assumed temperature (°F)
while true
Viscousity = V_1*exp(V_2/(Tf + 95)); % Viscousity (reyn)
S = (C_ratio)^2*((Viscousity*(N/60))/P); %Sommerfeld Number
delta_T = (TRV_2 + (TRV_3*S)+(TRV_4*(S^2)))*(P)/9.7; % Temperature Rise (°F)
T_average = Temp_in + (delta_T/2); % Average temperature
T_f = (Tf + T_average)/2; % Average assumed temperature (°F)
delta_T2 = Tf -T_average
% update the required variables for each iteration as per the need
% for eg Tf = T_f
if delta_T2 <= 0
break
end
end
Hope this helps!