You need to test each value of ‘P’, then do the appropriate calculation:
for k1 = 1:length(P)
Pn = P(k1);
if Pn<=P_v
phi(k1)=(phi_p_v)*(P_v./Pn).*exp((V_sat*(Pn-P_v))/(R*T));
else
phi(k1)=exp((P_r(k1))/(T_r)*(B_0+w*B_1));
end
end
I created ‘Pn’ for each value of ‘P’ and changed the first ‘phi’ equation to accommodate it. That also required subscripting ‘P_r’ and subscripting ‘phi’ in both equations.
Does this do what you want?