Obtaining variables from a list of values depending on user input

3 views (last 30 days)
Hello everybody: I am writing to ask for desperate help. I want to create a function which calculates the refractive index of silicon. As I haven't been able to find any formulas for this, I have instead found a list with different values of refractive index at different wavelengths in the form of a .txt file like shown below (extract):
Wavelength(nm)-refractive index-extinction coefficient
190.7 -0.847- 2.73
198.4 -0.968- 2.89
206.6 -1.11- 3.05
207.3 -1.036- 2.928
208 -1.046- 2.944
208.7 -1.066- 2.937
209.4 -1.07- 2.963
The idea is, that the user will insert a certain wavelength, and from that wavelength, the function will calculate the refractive index by looking into the list (the text file)and probably using the closest to the value inserted by the user, assigning then the correct value to the refractive index of Silicon.
SO; to make it simple: A function that when given a certain wavelength (input by the user) will look up the corresponding refractive index in the list assigning that value to a variable I will call nSi.
Is there any chance of someone telling me how to do this? Is there maybe a simpler way? Thanks everyone very much as I am doing a PhD and it is my first time programming with Matlab and I'm learning by myself...

Accepted Answer

Andreas Goser
Andreas Goser on 26 Jan 2012
This looks like a good use for Interpolation with the INTERP1 command. There are however multiple way to interpolate, fit, etc. Give it a try and if you run into problems, Post code and data.
  2 Comments
Guillermo Lopez
Guillermo Lopez on 26 Jan 2012
Thanks sooooooooooo much for your answer. It's been great help, and it actually has solved all my problems!!! Thank again

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!