%Oil Mixture % Coded by NFR on 1.24.2019 % This is another example of local functions % Also shows how to pass parameters % close all clc nu_a = 3.8; %centistokes nu_b = 13.9; %centistokes X = linspace(0,1,1000); % Mass fraction of A Nu_Mix_Refutas = VBNcalc2(nu_a,nu_b,X); plot(X,Nu_Mix_Refutas) hold on Nu_Mix_Gambill = GambillModel(nu_a,nu_b,X); plot(X,Nu_Mix_Gambill) hold off xlabel('Mol Fraction A') ylabel('Kinematic Viscosity') legend('Refutas Method','Gambill Method') % Define the local function for Gambill function Nu_mix = GambillModel(nu_a,nu_b,X) Nu_mix = (X*(nu_a)^(1/3)+(1-X)*(nu_b)^(1/3)).^3; end % This is the local function for Refutas function VBNcomp = VBNcalc(nu) VBNcomp = 14.534*log(log(nu+.8))+10.975; end function Nu_mix = VBNcalc2(nu_a,nu_b,X) % X is mass component of a VBN_1 = VBNcalc(nu_a); VBN_2 = VBNcalc(nu_b); VBNmix = X*VBN_1+(1-X)*VBN_2; Nu_mix = exp(exp((VBNmix-10.975)/14.534))-0.8; end