%e_r_z loop
for e_r_z=1:length(ratio)
if ratio(e_r_z)> 1.4
eta1(e_r_z)= 1.32/(1+ratio(e_r_z));
elseif ratio(e_r_z)< 0.06
eta1(e_r_z)= 1.0;
else
% approximation
eta1(e_r_z)= interp1([0.05 0.2 0.4 0.7 1.5],[1.0 0.9 0.8 0.7 0.4],ratio(e_r_z),'linear');
end
end
%Non e_r_z loop
if ratio> 1.4
eta2= ratio+5;
elseif ratio< 0.06
eta2= ratio-10;
else
eta2=ratio+10;
end
The upper program, caulate the single element.
The lower one, caulate the whole arrey:
maybe compare the every element of ratio arrey with the value(1.4/0.06) from beginning to the end, just like the upper program(e_r_z loop), find not every element of the arrey is greater than 1.4 or less than 0.06. So, make the choice else
, then, eta2=ratio+10;
, so, when come to the end of the program , every element of eta2 is added with 10, which means the elements which are greater than 1.4 and less than 0.06 also was added by 10.
So, if you want to agree the condition of one if loop, if ratio> 1.4, eta2= ratio+5;
it need every elements of the ratio arrey meet the condition.