If anyone needs to know the answer to this. It is because he is not doing element wise division
R=((n_S-1).^2)/((n_S+1).^2);
should be
R=((n_S-1).^2)./((n_S+1).^2);
Note the './' instead of '/' for division
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!