Skip to content

Instantly share code, notes, and snippets.

@lnacquaroli
Last active September 1, 2019 02:38
Show Gist options
  • Save lnacquaroli/8159fdfb38692a4d76e1f20912a28df6 to your computer and use it in GitHub Desktop.
Save lnacquaroli/8159fdfb38692a4d76e1f20912a28df6 to your computer and use it in GitHub Desktop.
Computes the reflection of a sequence n of refractive indexes wihtout interference and absorption effects
"""
Computes the reflection of a sequence of indices of refraction without interference and absorption effects.
y = multipleReflections(n)
author: Cuchu & lnacquaroli
"""
function multipleReflections(n::Array{Real})
R1::Float64 = 0.0
R::Float64 = 0.0
for i = 1:length(n)-1
R2 = ( (n[i] - n[i+1])/(n[i] + n[i+1]))^2
R = (R1 + R2 - 2.0*R1*R2)/(1.0 - R1*R2)
R1 = R
end
return R
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment