Obtaining variables from a list of values depending on user input

1 visualización (últimos 30 días)
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...

Respuesta aceptada

Andreas Goser
Andreas Goser el 26 de En. de 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 comentarios
Guillermo Lopez
Guillermo Lopez el 26 de En. de 2012
Thanks sooooooooooo much for your answer. It's been great help, and it actually has solved all my problems!!! Thank again
Andreas Goser
Andreas Goser el 26 de En. de 2012
My pleasure. Hint: Accept the answer then ;-)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by