Obtaining variables from a list of values depending on user input

조회 수: 2 (최근 30일)
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...

채택된 답변

Andreas Goser
Andreas Goser 2012년 1월 26일
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
Guillermo Lopez
Guillermo Lopez 2012년 1월 26일
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 2012년 1월 26일
My pleasure. Hint: Accept the answer then ;-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by